jquery - css clear floats with multiple divs -


i need clear floats after left , right div..ie; left div should match whole size of right div..but unfortunately dont see working.

css

#left{     float:left;     background-color:gray }  #right{     float:left;     background-color:gray } 

html

<div>      <div id="left">        <ul id="ul1" style="list-style-type:none">           <li><a style="color:orange" href="/">about us</a></li>                         <br>           <li><a style="color:orange" href="/players">players</a></li>                         <br>          <li><a style="color:orange" href="/contactus">contact us</a></li>         </ul>      </div>      <div id="right">         content.         <br>         content.             <br>         content.                 <br>         content.                     <br>         content.                         <br>         content.                              <br>         content.                                 <br>         content.                                     <br>         content.<br>         content.     </div>      <div style="clear: both;"></div> </div>                                      <div style="clear: both;"></div> <div> </div>     

http://jsfiddle.net/verja6oh/

there's cool trick on how this.

first, apply padding-bottom:100%; each div.

next, apply margin-bottom:-100%; each div.

finally, add overflow:hidden; div inside.

presto! true happiness yours.

jsfiddle demo

css:

#top{background:yellow;overflow:hidden;} #left{float:left;background-color:gray;padding-bottom:100%;margin-bottom:-100%;} #right{float:left;background-color:gray;padding-bottom:100%;margin-bottom:-100%;} 

note added id container div styled.

references:

http://www.ejeliot.com/blog/61


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -