我有一个带有一些填充的包装器,然后我有一个具有百分比宽度(40%)的浮动相对div.
在浮动的相对div中,我有一个固定的div,我希望它的大小与其父目录的大小相同.我知道从文档流中删除了固定的div,因此忽略了包装器的填充.
HTML
<div id="wrapper">
<div id="wrap">
Some relative item placed item
<div id="fixed"></div>
</div>
</div>
CSS
body {
height: 20000px
}
#wrapper {
padding: 10%;
}
#wrap {
float: left;
position: relative;
width: 40%;
background: #ccc;
}
#fixed {
position: fixed;
width: inherit;
padding: 0px;
height: 10px;
background-color: #333;
}
这是必备的小提琴:http://jsfiddle.net/C93mk/489/
有没有人知道有什么方法可以做到这一点?
I have amended the fiddle to show more detail on what I am trying to accomplish, sorry for the confusion: http://jsfiddle.net/EVYRE/4/个