[英]floating div 100% width
I'm using the Foundation framework and I want to make a navigation which takes 100% width of the grid class. 我正在使用Foundation框架,我想进行一个导航,该导航需要100%的网格类宽度。
I have 3 divs: .header_beg
, .header_rep
, .header_end
我有3个div:
.header_beg
, .header_rep
, .header_end
.header_beg
is 2px width
, float: left
and the .header_end
also .header_beg
的2px width
为2px width
, float: left
, .header_end
也
But I want header_rep
to be 1px width and to repeat-x
till it fills 100% of the grid class. 但我希望
header_rep
宽度为1px,并repeat-x
直到填充100%的网格类。 But it also need it to be float: left
, but with float: left
it's not visible. 但它还需要将其设置为
float: left
,但使用float: left
则不可见。 I haven't set width because I want it to be 100% of the grid class. 我没有设置宽度,因为我希望它是网格类的100%。
background: red;
height: 49px;
margin-left: 2px;
Here's a fiddle: http://jsfiddle.net/WFVER/ 这是一个小提琴: http : //jsfiddle.net/WFVER/
I need the green divs
to be at the beginning and at the end of the red one, and simultaneously the 3 divs
to be 100% width of the grid class. 我需要将绿色
divs
放置在红色divs
的开始和结尾处,并将3 divs
同时设为网格类的100%宽度。
You can do this with floats but instead of doing it via floats, I will show you how to do this with absolute position: 您可以使用浮点数来执行此操作,而不是通过浮点数来执行操作,我将向您展示如何在绝对位置上执行此操作:
HTML HTML
<div class="header">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
CSS CSS
.header {
width: 1000px;
height: 20px;
position: relative;
}
.header .left {
width: 1px;
left: 0;
height: 20px;
}
.header .right {
width: 1px;
right: 0;
height: 20px;
}
.header .middle {
width: 998px;
background: url(images.png) repeat-x;
left: 1px;
right: 1px;
height: 20px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.