2015-12-29 124 views
0

我的圖像位置出現了一個小問題,所以問題在於,我有我的肖像視圖我滑過圖像,當我切換視圖(肖像爲橫向)時,圖像不再是中心。我的問題是我的圖像的邊距仍然與縱向視圖相同,我不知道如何改變它。當我更改我的手機視圖時,圖像的位置

我已經試圖改變我的圖像邊距,但沒有做任何事情,它仍然採用我使用的第一個視圖邊距。

所以這裏是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; } 

回答

0

只是這個CSS添加到您的圖像類

.myImage { 
display: block; 
margin-right: auto; 
margin-left: auto; 
} 

它應該工作!

+0

嗡嗡聲我已經這樣做了我的邊際:0汽車; 但我試過你的代碼,仍然發生同樣的事情:s – Kira

相關問題