的jsfiddle:https://jsfiddle.net/DTcHh/19451/定影圖像上滾動移動位置
我建立使用引導3.在滾動一個網站,我有一個改變位置固定附着在頁面圖像。然而,這種方法很有效,但一旦變得固定,它總是會移位。我知道這與利潤率有關(並且我使用了像素,這似乎實際上解決了問題,剩下的餘量需要爲響應式網站的%)。下面的代碼:
HTML
<div class="row">
<div class="col-sm-5">
<h2 class="white">Some Text</h2>
</div>
<div class="col-sm-7">
<img class="img-responsive screen-phone" src="img/phone.png">
</div>
</div><!--END ROW-->
CSS
.screen-phone{
max-width:300px;
margin-top:25px;
margin-left:25%;
z-index:999;
}
的Javascript
$(document).ready(function(){
$(window).scroll(function() {
if ($(this).scrollTop()>1120){
$('.screen-phone').css('position','fixed').css('top','0');
}else{$('.screen-phone').css('position','static');
};
});
});
把網站上時,並在完成時,這只是導致手機關閉屏幕完全移動小提琴,它仍然從它的初始位置轉移。 – user5854648