javascript - Adding a button element changes the position of the div it is in? -


i have basic layout 6 dynamically sized panels content, arranged in 2 rows , 3 columns.

the panels <div>'s , set width of 26% 2% margins, , display:inline-block;.

they evenly spaced , correct, add <button> element, box in 1st row, , 2nd column shifts 20 pixels.

any ideas?

html:

<!doctype html> <html> <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8">     <title>test client</title>     <link rel='stylesheet' type='text/css' href='css/main.css' />     <script src="javascript/main.js">     </script> </head> <body onload="main.onload();">     <div class="panel">         <h3>content</h3>         <div class="innercontainer" id="">         </div>     </div>     <div class="panel">         <h3>content</h3>         <div class="innercontainer" id="">         </div>     </div>     <div class="panel">         <h3>content</h3>         <div class="innercontainer" id="">         </div>     </div>     <div class="panel">         <h3>content</h3>         <div class="innercontainer" id="">         </div>     </div>     <div class="panel">         <h3>content</h3>         <div class="innercontainer" id="">         </div>     </div>     <div class="panel">         <h3>concent</h3>         <div class="innercontainer" id="">         </div>     </div> </body> </html> 

css:

*, *:before, *:after {     -moz-box-sizing: border-box;     -webkit-box-sizing: border-box;     box-sizing: border-box; }  html {     margin: 0;     padding: 0;     height: 100%; }  body {     margin: 0;     padding: 0;     background-color: rgb(227, 111, 30);     height: 100%; }  .innercontainer {     margin:0;     padding:0;     width:100%; }  .panel {     display: inline-block;     clear:none;     width: 26%;     height: 41%;     margin: 2%;     padding: 30px;     border: 2px solid black;     box-shadow: 10px 10px 5px #888888;     -moz-border-radius: 40px;     -webkit-border-radius: 40px;     border-radius: 40px; /* future proofing */     -khtml-border-radius: 40px; /* old konqueror browsers */     background-color: white; }  .panel h3 {     text-align: center;     text-transform: uppercase;     padding:0;     margin:0;     clear:both; }  .panel button { } 

try using vertical-align:top. see fiddle working example: http://jsfiddle.net/dxgsn/1/

so css be:

.panel {    display: inline-block;    clear:none;    width: 26%;    height: 41%;    margin: 2%;    padding: 30px;    border: 2px solid black;    box-shadow: 10px 10px 5px #888888;    -moz-border-radius: 40px;    -webkit-border-radius: 40px;    border-radius: 40px; /* future proofing */    -khtml-border-radius: 40px; /* old konqueror browsers */    background-color: white;    /*add line*/    vertical-align:top; } 

or alternatively, use float:left instead of display:inline-block. see fiddle: http://jsfiddle.net/dxgsn/2/

display: block; float: left; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -