alignment - CSS inline-block fixed width tiles -


i'm building tile-based portfolio wordpress theme, , can't tiles center correctly in parent div. here's static page (i'm migrating .cu.cc asap). i've used inline-block align them on 1 row, , there margin styles keep gaps between tiles, i'm getting (red lines added):

faulty align

i'd align tiles flush red lines - how can it?

here's boiled down version of html:

<div class="content-wrapper"> <div class="tile"></div> <div class="tile"></div> <div class="tile"></div> </div> 

and css:

.content-wrapper{ width: 678px; margin-top: 66px; margin-left: auto; margin-right: auto; text-align: center; } .tile{ display:inline-block; width: 182px; height: 295px; background-color: #e1e1e1; border: solid 1px rgba(176,176,176,0); margin-bottom: 64px; margin-right: 35px } 

thanks, oliver

i'll add karl-andré's answer noting :last-child not supported in ie8, nice switch to

.content-wrapper .tile {    margin-left: 10px; } .content-wrapper .tile:first-child {    margin-left: 0px; } 

even more clever decision use following:

.content-wrapper .tile + .tile {    margin-left: 10px; } 

just 3 lines instead of six, elegant , works everythere.

also, if you're bored of manually typing margin , want justify-like behaviour, consider fluid width equally spaced divs.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -