【发布时间】:2016-04-03 10:18:59
【问题描述】:
我的图像位置有一个小问题,所以问题出在这里,我有我的纵向视图,我滑动我的图像,当我切换我的视图(纵向到横向)时,我的图像不再居中。我的问题是图像的边距仍然与纵向视图相同,我不知道如何更改。
我已经尝试更改图像的边距,但无事可做,它仍然是我使用的第一个视图边距。
所以这里是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; }
【问题讨论】:
标签: javascript image css mobile position