我在 http://jsfiddle.net/Dx5d8/ 重现了这个问题
我有一个 100% 宽和 200 像素高的背景 div,最小宽度为 600 像素。我在里面有五个 float 的 div。
是否可以随着布局宽度的变化,扩展背景 div 的宽度以覆盖 float 的 div?
如有任何帮助,我们将不胜感激!
#stripe {
height: 200px;
width: 100%;
min-width:600px;
text-align: center;
position: relative;
background-image: url(http://signaturewebdesign.net/egro14/14_images/brown_stripe_bg.png);
background-repeat: repeat;
}
.holder {
float: left;
height: 200px;
width: 125px;
display: inline-block;
padding-right: 13px;
padding-left: 12px;
margin: auto;
}
最佳答案
如果您希望当元素占据多于一行时改变高度,您可以添加overflow:hidden
并将height
设置为auto
为你的 #stripe
风格:
#stripe {
height: auto;
width: 100%;
min-width:600px;
text-align: center;
position: relative;
background-image: url(http://signaturewebdesign.net/egro14/14_images/brown_stripe_bg.png);
background-repeat: repeat;
overflow:hidden;
}
关于css - 使 CSS 在不同尺寸下更流畅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20025655/