The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Center multiple images (gallery) inside div Reply To: Center multiple images (gallery) inside div


center image horizontally:

img {
    display: block;
    margin: 0 auto;

vertical alignment is a little trickier… you could use the display: table method… or checkout Chris Coyiers pseudo element method – t’is pretty sexy!

<div class="container">
  <div class="container__inner">
    <img src="spam.jpg" alt="Spam Javelin" />

.container { display: table; } 
.container__inner { display: table-cell; vertical-align: middle; }

if you only need to support modern browsers you could use transform.