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;     } 

jsfiddle


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -