-4

Can't figure how to center these 3 img elements horizontal

HTML

<!-- Homepage Content -->
<div id="center">

    <img src="images/homepage/wedding.png"/>
    <img src="images/homepage/wildlife.png"/>
    <img src="images/homepage/portrait.png"/>

</div> 

CSS

#center {
display:inline-block;
margin-left:auto;
margin-right:auto;
}

Fairly simple huh but it doesnt work! Test page

Sammy Kumar
  • 121
  • 3
  • 15

1 Answers1

3

You just need to add text-align: center for your #center

<div id="center">

   <img src="images/homepage/wedding.png"/>
   <img src="images/homepage/wildlife.png"/>
   <img src="images/homepage/portrait.png"/>

</div> 

CSS

#center{
  display: block;
  padding: 20px;
  text-align: center;
  border: 1px solid #000;
}
#center img{
  display: inline;
}

Check this link to see demo.

Aldi Unanto
  • 3,626
  • 1
  • 22
  • 30