html - Set a Fixed div to 100% width of the parent container -
i have wrapper padding, have floating relative div percentage width (40%).
inside floating relative div have fixed div same size parent. understand fixed div removed flow of document , such ignoring padding of wrapper.
html
<div id="wrapper"> <div id="wrap"> 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; }
here obligatory fiddle: http://jsfiddle.net/c93mk/489/
does know of way accomplish this?
i have amended fiddle show more detail on trying accomplish, sorry confusion: http://jsfiddle.net/evyre/4/
you can use margin .wrap container instead of padding .wrapper:
body{ height:20000px } #wrapper { padding: 0%; } #wrap{ float: left; position: relative; margin: 10%; width: 40%; background:#ccc; } #fixed{ position:fixed; width:inherit; padding:0px; height:10px; background-color:#333; }
Comments
Post a Comment