我的页面右侧似乎有一些过度的水平滚动。
我推断这与我网站顶部的脚本有关——当我删除它时,问题就会自行解决。
只是为了让您了解我希望实现的目标;我希望顶部的图像跨越浏览器的 100% 宽度,但保持类型居中。
当您第一次访问该站点时,您会很好地了解我在说什么。
http://cargocollective.com/btatest
提前致谢
迈克尔
编辑
代码如下:
<script type="text/javascript">
// The social div
var $socialDiv,
// The social div's height
socialDivHeight = 560,
currentSocialDivHeight = socialDivHeight;
$(document).ready(function() {
$socialDiv = $('.social');
$socialDiv.css({
'background-image': 'url(http://a3.sphotos.ak.fbcdn.net/hphotos-ak-prn1/563655_324264884301748_471368753_n.jpg)',
'background-repeat': 'no-repeat',
'background-attachment': 'fixed',
'background-size' : '110% auto',
'height' : socialDivHeight + 'px',
'margin-left' : '-100%',
'margin-right' : '-100%',
});
});
$(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>