html - How to start a new line after float:left with different height? -


i have code on jsfiddle.

as see 3rd or 4th li item starting in new line (depending on window width). new line not started @ beginning of line because of different heights.

how can in css new lines starts always @ beginning of lines?

<ul>     <li>         <div class="imgplace" style="height:200px;">here img in real</div>         <input type="text" id="img_01" value="blahblah" />         <div class="imgicon">i1</div>         <div class="imgicon">i2</div>         <div class="selector">             <input type="radio"> check me         </div>     </li>     <li>         <div class="imgplace" style="height:190px;">here img in real</div>         <input type="text" id="img_02" value="blahblah" />         <div class="imgicon">i1</div>         <div class="imgicon">i2</div>         <div class="selector">             <input type="radio"> check me         </div>     </li>     <li>         <div class="imgplace" style="height:180px;">here img in real</div>         <input type="text" id="img_03" value="blahblah" />         <div class="imgicon">i1</div>         <div class="imgicon">i2</div>         <div class="selector">             <input type="radio"> check me         </div>     </li>     <li>         <div class="imgplace" style="height:200px;">here img in real</div>         <input type="text" id="img_04" value="blahblah" />         <div class="imgicon">i1</div>         <div class="imgicon">i2</div>         <div class="selector">             <input type="radio"> check me         </div>     </li>     <li>         <div class="imgplace" style="height:200px;">here img in real</div>         <input type="text" id="img_05" value="blahblah" />         <div class="imgicon">i1</div>         <div class="imgicon">i2</div>         <div class="selector">             <input type="radio"> check me         </div>     </li>     <li>         <div class="imgplace" style="height: 150px;">here img in real</div>         <input type="text" id="img_01" value="blahblah" />         <div class="imgicon">i1</div>         <div class="imgicon">i2</div>         <div class="selector">             <input type="radio"> check me         </div>     </li> </ul>  ul { width: 650px; } li {     display: block;     width: 200px;     float: left;     margin: 2px; } .imgplace {     width: 200px;     background: #f00; } .imgicon {     display: block;     float: left;     width: 16px;     height: 16px; } } 

just remove float:left , add display: inline-block , vertical-align: top align them better(+1 hashem comments)

try

li {    display: inline-block;    width: 200px;    margin: 2px;    vertical-align: top; } 

demo


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -