html - How to make width: auto work with float? -


i noticed there several guestions type of problem 2 divs inside wrapper , without floats not able find floats , several divs.

so here guestion: how can make container div fill rest of width automaticly? need keep floats , display: inline-block etc solutions not fix that.

please feel free copy code notepad can see live:

<html> <head> <style> #wrapper {     width: 100%;     height: 100%;     border: 1px black solid; }  .block1 {        width: auto;        float:left;        min-height: 500px;        display: inline-block;        background-color: green; } .block2 {        display: inline-block;        float:left;        min-height: 500px;        width: 200px;        background-color: red;     } .block3 {        display: inline-block;        float:left;        height: 30px;        width: 10%;        background-color: yellow;     } .block4 {        display: inline-block;        float:left;        height: 30px;        width: 90%;        background-color: purple;     } </style> </head> <body>  <div id="wrapper">     <div class="block4">topmenu</div>     <div class="block3">profilebar</div>     <div class="block2">leftmenu</div>     <div class="block1">content</div> </div>  </body> </html> 

here jsfiddle example

remove float , display .block1 , set margin-left , margin-top so:

.block1 {     width: auto;     min-height: 500px;     margin-top:30px;     margin-left:200px;     background-color: green; } 

here working example


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -