1
我已經添加了一些腳本來我的網站:http://cargocollective.com/btatest移動jQuery的下跌
不過,我很想把它向下移動40像素。
我試圖把它包裝在一個div中,但無濟於事。
這裏的腳本:
<script type="text/javascript">
// The social div
var $socialDiv,
// The social div's height
socialDivHeight = 500,
currentSocialDivHeight = socialDivHeight;
$(document).ready(function() {
$socialDiv = $('.social');
$socialDiv.css({
'background-image': 'url(http://fearthegrizzly.com/productions/theacrobat/web3.jpg)',
'background-repeat': 'no-repeat',
'background-attachment': 'fixed',
'background-size' : '110% 100%',
'height' : socialDivHeight + 'px',
'margin-left' : '-50%',
'margin-right' : '-50%',
});
});
$(window).scroll(function() {
//Get scroll position of window
var windowScroll = $(this).scrollTop();
var newSocialDivHeight = Math.max(0, socialDivHeight - windowScroll);
if (Math.abs(newSocialDivHeight - currentSocialDivHeight) < 1)
return;
$socialDiv.css({
'opacity' : 1 - windowScroll/400
});
currentSocialDivHeight = newSocialDivHeight;
});
</script>
任何幫助,將不勝感激。
感謝
邁克爾
你想換什麼* *在'div' ?而且你想將頁面上的*什麼* – 2012-07-13 20:57:23
您想將腳本移動40px?如果你的意思是一些實際的元素,比如'div',你可以做'margin-top:40px'或'position:relative;頂部:40px' – MrOBrian 2012-07-13 20:58:49