I have an image gallery in a website I'm working on. I wanted to center the image gallery, so I added 'text-align:center' to it. It works fine, but what I wanted was to center the entire image gallery on the page and still to left align images inside it. How do I do it?
HTML
<section>
<article class="img1">
<a href=""><img src="img/img1.png"></a>
<dl>
<a href="#"><dt>Image Title</dt></a>
<dd>Image Description</dd>
</dl>
</article>
<article class="img2">
<a href=""><img src="img/img2.png"></a>
<dl>
<a href="#"><dt>Image Title</dt></a>
<dd>Image Description</dd>
</dl>
</article>
<article class="img3">
<a href=""><img src="img/img3.png"></a>
<dl>
<a href="#"><dt>Image Title</dt></a>
<dd>Image Description</dd>
</dl>
</article>
</section>
CSS
section {
margin-top: 100px;
/* the gap between top navigation above */
text-align: center;
}
.img1,
.img2,
.img3 {
display: inline-block;
vertical-align: top;
width: 250px;
height: auto;
margin: 0 1%;
padding: 0;
}
article img {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
article dl {
display: block;
width: 100%;
margin-top: 10px;
text-align: left;
}
article dt {
font-size: 0.9em;
font-weight: 400;
}
article dd {
margin-left: 0;
font-size: 0.9em;
font-weight: 300;
}