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