更改移动视图时图像的位置
position of my image when i change my mobile view
我的图像位置有一个小问题,所以问题来了,我有我的纵向视图,我滑动我的图像,当我切换视图(纵向到横向)时,我的图像不再居中。我的问题是,我的图像的边缘仍然与肖像视图相同,我不知道如何改变这一点。
我已经试着改变我的图像边距,但没什么可做的,它仍然是我使用的第一个视图边距。
这就是Js/Jq
:
function puceTransition(front) {
var wrapImg = $('.wrapImage');
var margeLeft = 0;
if(front) {
if (stateImg == "back") {
stateImg = "front";
margeLeft = $('#myImageBack').css("marginLeft").replace("px", "");
$('#frontImg').addClass('select');
$('#backImg').removeClass('select');
$('#myImageBack').animate({opacity: "0.5", marginLeft: ((imgFront + widthImg1 + myButtonRight)) + "px"}, "normal");
$('#myImageFront').animate({opacity: "1.0", marginLeft: parseInt(margeLeft) + "px"}, "normal");
$('.imgTitleBack').hide();
$('.imgTitleFront').show();
$('#imgButtonLeft').animate({opacity: "0.5"});
$('#imgButtonRight').animate({opacity: "1.0"});
}
} else {
if (stateImg == "front") {
stateImg = "back";
margeLeft = $('#myImageFront').css("marginLeft").replace("px", "");
$('#backImg').addClass('select');
$('#frontImg').removeClass('select');
$('#myImageFront').animate({opacity: "0.5", marginLeft: (((-imgFront) + (-widthImg1) + myButtonLeft)) + "px"}, "normal");
$('#myImageBack').animate({opacity: "1.0", marginLeft: parseInt(margeLeft) + "px"}, "normal");
$('.imgTitleBack').show();
$('.imgTitleFront').hide();
$('#imgButtonLeft').animate({opacity: "1.0"});
$('#imgButtonRight').animate({opacity: "0.5"});
}
}
}
这是css:
.myImage { display: block; position: relative; width: 450px; margin: 0 auto; }
.myImage.second { margin: -240px 0 0 670px; }
.myImageAirport { display: block; position: relative; width: 450px; margin: 0 auto; }
.myImageAirport.second { margin : -220px 0 0 670px; }
只需将此css添加到图像类中
.myImage {
display: block;
margin-right: auto;
margin-left: auto;
}
它应该起作用!
相关文章:
- javascript背景图像位置循环
- 使用JavaScript功能切换图像位置
- 视差'背景图像/位置/附件'jQuery的动画很不稳定
- 通过图像计数计算图像位置
- 如何在jquery中使用图像ID获取图像位置
- 在 HTML5 画布中,图像位置在设备之间更改
- 根据图像位置目录附加 CSS 样式
- 似乎无法使用关键事件更改图像位置
- 使用图形 API 检索照片的图像位置
- 具有自定义图像位置的全屏背景幻灯片(每张幻灯片)
- 使图像(位置:固定)仅在DIV内部可见
- 基于鼠标单击坐标显示图像位置
- 如何使用javascript更改网站上的背景图像位置
- 用javascript设置图像位置,不总是正确放置
- Javascript图像位置
- 如何在点击按钮时实现背景图像位置变化的幻灯片效果
- Javascript光标图像位置
- 链接或按钮鼠标悬停弹出框/图像位置更改
- 刷新页面后图像位置不正确
- 使用绝对图像位置