我好像在页面的右侧有一些过度的水平滚动。全宽问题第2部分
我已经推断它是与我的网站顶部的脚本有关 - 当我删除它时,问题自行解决。
只是想给你一个我希望实现的想法;我想要顶部的图像跨越浏览器的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>
嘿,现在你可以改变你的代码,如果是的话,请创建一个jsfiddle链接,并把你的HTML和CSS代码....... – 2012-08-01 09:39:04
请把你的代码你试过了吗? – Vins 2012-08-01 09:39:19
耶,jsfiddle会帮助...很难让我看到是什么原因造成的。虽然你可以尝试'html,body {width:100%}' – neokio 2012-08-01 09:41:28