【发布时间】:2014-04-21 14:09:31
【问题描述】:
是否可以让父级(位置:相对)通过其绝对子级自动扩展其宽度? 这是我的 jsfiddle 链接:http://jsfiddle.net/YD2Xu/
理想的是#container 和#full-width 应该与#large-width 具有相同的宽度。
CSS:
#container {
position: relative;
border: 1px solid green;
}
#large-width, #full-width {
display: table;
position: absolute;
}
#large-width {
white-space: no-wrap;
width: 1500px;
height: 200px;
border: 1px solid red;
}
#full-width {
top: 30px;
width: 100%;
border: 1px solid blue;
}
HTML:
<div id="container">
<div id="large-width">
this is large width
</div>
<div id="full-width">
this is full width
</div>
</div>
我需要通过 css 来实现,不要使用 javascript。有谁知道该怎么做?
非常感谢。
【问题讨论】: