I'm working on a layout where I have a container with padding and a floating relative div that takes up 40% of the width.
Within this floating div, I have a fixed div that I want to be the same size as its parent. I know that a fixed div is taken out of the normal document flow and doesn't adhere to the padding of the container.
HTML
<div id="wrapper">
<div id="wrap">
Some content inside the relative div
<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;
}
Check out the example in this fiddle: http://jsfiddle.net/C93mk/489/
Can anyone suggest a solution for achieving this layout?
I've updated the fiddle to provide more clarity on what I'm trying to achieve. Sorry for any confusion: http://jsfiddle.net/EVYRE/4/