HTML5/CSS - When content is added to a SECTION the position moves. Why? -


i'm having trouble understanding why section within layout moving positions when content added it. intention have 3 sections per row horizontally aligned each other. appreciated, thanks.

jsfiddle - http://jsfiddle.net/z6mx3/1/

css

body {     margin:0px;     padding:0px; }  #container {     background-color:silver;     width:1024px;     margin:auto;     padding-left:10px;     padding-right:10px;      padding-bottom:20px;     min-height:100%;     position:absolute;     left:0;     right:0; }  #content {     font-family:arial, helvetica, sans-serif;     color:#664e44;     background-color:red;     overflow:auto; }   section {     color:#24292e;     width:300px;     height:500px;     display:inline-block;     margin: 0 15px;     background-color:#a8b1b1;     padding:4px; } 

html

<!doctype html> <html lang="en">     <head>         <title>test</title>         <link rel="stylesheet" type="text/css" href="style.css">     </head>     <body>         <div id="container">                                     <div id="content">                 <section>                 <h2>header</h2>                 <p></p>                 </section>                  <section>                  </section>                  <section>                 </section>                  <section>                 </section>                  <section>                 </section>                  <section>                 </section>             </div>         </div>     </body> </html> 

the default alignment inline-block items baseline.

you need add correct alignment option css

section {     color:#24292e;     width:300px;     height:500px;     display:inline-block;     margin: 0 15px;     background-color:#a8b1b1;     padding:4px;     vertical-align:top /* here*/  } 

jsfiddle demo


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -