html - CSS Display:inline-block | 3 columns | No floats -


i trying 3 column design, out using floats.

html

<header>this header</header> <div id="body">     <div id="col-1" class="col">this column - column - column - column</div>     <div id="col-2" class="col">this column - column - column - column</div>     <div id="col-3" class="col">this column - column - column - column</div> </div> 

css

    * {         margin:0;         padding:0;     }     header {         background:#4679bd;         width:90%;         height:70px;         line-height:70px;         font-size:20px;         text-align:center;         border:1px solid #333;         margin:10px auto;     }     #body {         width:700px;         margin:auto;         border:1px solid #333;     }     #body .col {         display:inline-block;         background:#ccc;         height:500px;         border:1px solid #333;         margin:5px;     }     #body #col-1 {         width:100px;     }     #body #col-2 {         width:200px;     }     #body #col-3 {      width:350px; } 

http://jsfiddle.net/chaos67731/fmzpr/5/

when give columns width on class ".col" stay top, when give each column width id , make them different, step see in link above.

what fix , why happen?

by default, inline-block element's vertical alignment baseline.

simply set vertical-align:top on .col.

#body .col {     vertical-align: top; } 

working jsfiddle here


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -