调整窗口大小时标题图像停止重复
所以我在页面顶部粘贴了一张图像,该图像一直在顶部重复。由于某种原因,当我调整窗口大小然后向右滚动时,它会停止重复。 div 是包装器之外的文档中的第一个。有什么想法吗?
#header {
background-image:url('http://daveywhitney.com/img/paperhead.png');
background-repeat: repeat-x;
width: 100%;
height: 145px;
margin:0 0 20px 0;
}
So i have an image in stuck to the top of my page that repeats all the way across the top. For some reason when I resize the window and then scroll over to the right it stops repeating. The div is the first in the document outside of the wrapper. Any ideas?
#header {
background-image:url('http://daveywhitney.com/img/paperhead.png');
background-repeat: repeat-x;
width: 100%;
height: 145px;
margin:0 0 20px 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这似乎在 FireFox 中工作得很好。调整窗口大小时检查父元素的宽度。
This seems to work fine in FireFox. Check the width of the parent element when you resize the window.
您的代码设置的可用基准是:-
,假设图像的宽度为 250 像素 & 250 像素。整个浏览器屏幕的宽度为 1024px。因此从技术上讲,图像将水平重复至少 5 次,其中全尺寸重复 4 次,全尺寸重复 4 次。最后一个将显示一点。
现在,如果您调整浏览器的大小或在弹出窗口中查看相同的网页,您的浏览器屏幕的宽度必然会被修改。假设现在您的浏览器屏幕宽度为 220px。由于图像宽度大于浏览器屏幕宽度(在这个特定的测试用例中),因此图像根本不会重复,&您也将无法看到完整图像。
并不是说有什么bug,只是逻辑部分,我们需要理解。
希望有帮助。
The available benchmarks as set by your code are:-
Internally, say the width of the image be 250px & the width of your full browser screen be 1024px. So technically, the image will repeat horizontally at least 5 times, with 4 times in full size & the last one will be shown a little bit.
Now, if you resize the browser or view the same web page in a pop-up window, your browser screen is bound to have its width modified. Let's say that now your browser screen width is 220px. As the image width is greater than the browser screen width (in this particular test case), so the image will not repeat at all, & you will also not be able to see the full image.
It's not that there is any bug, it's just the logical part, which we need to understand.
Hope it helps.
从您提供的详细信息中很难看出,但这里有一个可能可以解决问题的答案。添加以下内容
It's hard to tell from the details you have provided but here is a answer that might do the trick. Add the following
您需要添加一个
min-width
使其略大于您的主要内容。You need to add a
min-width
to be slightly larger than your main content.