【发布时间】:2015-03-14 23:58:54
【问题描述】:
有没有办法固定定位的 div 可以继承父级的宽度?
我知道固定宽度是相对于窗口的,所以这段代码不起作用:
#wrapper{
position: relative;
width:500px;
height: 20px;
background-color: blue;
}
#header{
position: fixed;
width: 100%;
height: 20px;
background-color: rgba(255,0,0,0.5);
}
<div id="wrapper">
#wrapper
<div id="header">
#header
</div>
</div>
【问题讨论】: