css - Removing unwanted vertical space between 2 divs -


i'm having trouble aligning #totalavailable2 bottom of #container2. got work #container1 , #totalavailable, you'll see in jsfiddle below.

jsfiddle demo: http://jsfiddle.net/7rwjr/2

html

<div id = "outercontainer">     <ul>         <li id="firstlist">             <div id="container1">                 <div id = containter1header>mobile chef</div>                 <div id = "innercontainer">                     <!-- content goes here -->                 </div>             </div>             <div id="totalavailable">total:<span id = "span"></span></div>         </li>         <li id="secondlist">             <div id="container2">                 <div id = containter2header>mobile chef</div>                 <div id = "innercontainer">                     <!-- content goes here -->                 </div>             </div>         </li>         <div id="totalavailable2">total:<span id = "span2"></span></div>     </ul> </div>   

css

/*********************************/ /* begin outer container styling*/ /*********************************/  #outercontainer ul li {     list-style: none; } #outercontainer ul li#firstlist {     list-style: none;     float: left; } #outercontainer ul li#secondlist {     list-style: none;     padding: 0px;     margin:0px; }  /*********************************/ /* end outer container styling*/ /*********************************/   /*********************************/ /* begin inner container styling*/ /*********************************/  #innercontainer {     margin-left: 30px; } #totalavailable {     height: 50px;     width:  490px;     background-color: black;     color: white;     font-size: 23px;     font-weight: bold;     padding-left: 10px;     padding-top: 15px;     font-family: arial;     border-width: 4px;     border-style: solid;     border-color: gray;     margin-left: 10px;     border-top-style: none; } #totalavailable2 {     height: 50px;     width:  490px;;     background-color: black;     color: white;     font-size: 23px;     font-weight: bold;     padding-left: 10px;     padding-top: 15px;     font-family: arial;     border-width: 4px;     border-style: solid;     border-color: gray;     display: inline-block;     border-top-style: none;     margin-left: 40px }  /*********************************/ /* end inner container styling*/ /*********************************/   #container1 {     background: url("http://www.anytimeinteractive.com/dev/test/images/bgdk.jpg");;     margin-left: 10px;     margin-top: 40px;     padding-bottom: 20px;     border-width: 4px;     border-style: solid;     border-color: gray;     overflow: auto;     height: 600px;     width: 500px;     overflow: auto; }  #container2{     height: 600px;     width: 500px;     background: url("http://www.anytimeinteractive.com/dev/test/images/bgdk.jpg");;     margin-left: 40px;     margin-top: 40px;     padding-bottom: 20px;     border-width: 4px;     border-style: solid;     border-color: gray;     display: inline-block;     overflow: auto; } 

thanks!

updated demo

html changes

    <!-- moved div inside li tag -->     <div id="totalavailable2">total:<span id = "span2"></span></div> </li> 

the #totalavailable2 div directly inside ul. type of element that's allowed directly inside ul li. part of html invalid , might cause problems in browsers. i'm guessing meant put inside li, did #totalavailable.

css changes

#outercontainer ul li#secondlist {   /* secondlist -> secondlist */     overflow: hidden;   /* added */     ... } #container2 {     /* display: inline-block; */   /* removed */     ... } #totalavailable2 {     /* display: inline-block; */   /* removed */     ... } 

there typo in css: #secondlist instead #secondlist.

after , above html change, removing inline-block #container2 , #totalavailable2 , adding overflow:hidden; #secondlist seemed fix it.

the use of overflow: hidden

if there columns, , 1 of them floated, adding overflow: hidden non-floated column prevents content wrapping around below floated columns (the way paragraph of text wraps around floated image).

as side effect of this, if non-floated column has width of 100% (explicitly or default), overflow: hidden cause fill remaining space in parent container, without overlapping floated columns. there's no need add horizontal margin non-floated column, prevent overlapping. makes easier create variable-width columns.

here's article explains how works.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -