html - Center multiple inline blocks with CSS and align the last row to the left -


i want horizontally center few inline blocks, @ same time have them align left on last row (see below).

the problem achieved (http://jsfiddle.net/5jsag/):

|        _____   _____        | |       |     | |     |       | |       |  1  | |  2  |       | |       |_____| |_____|       | |            _____            | |           |     |           | |           |  3  |           | |           |_____|           | 

while want this:

|        _____   _____        | |       |     | |     |       | |       |  1  | |  2  |       | |       |_____| |_____|       | |        _____                | |       |     |               | |       |  3  |               | |       |_____|               | 

you can see sample html @ http://jsfiddle.net/5jsag/.

i have tried using column-count , column-width doesn't work want to, because order of blocks changes:

|        _____   _____        | |       |     | |     |       | |       |  1  | |  3  |       | |       |_____| |_____|       | |        _____                | |       |     |               | |       |  2  |               | |       |_____|               | 

found quite simple solution problem: add filler divs @ end, of same width blocks aligned.

http://jsfiddle.net/5jsag/34/

html:

<div style="text-align:center">     <div class="entry">1</div>     <div class="entry">2</div>     <div class="entry">3</div>     <div class="entry">4</div>     <div class="entry">5</div>     <span class="fill"></span>     <span class="fill"></span>     <span class="fill"></span>     <span class="fill"></span> </div 

css:

.fill {     display:inline-block;     width:100px;     height:0px;     line-height:0px;     font-size:0px; }  .entry  {      display:inline-block;     margin-top:10px;     width:100px;     height:60px;     padding-top:40px;     border:1px solid red; } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -