Re: How to center a list when display:block?
- From: Bergamot <bergamot@xxxxxxxx>
- Date: Tue, 07 Oct 2008 10:01:23 -0500
SM wrote:
I have a list (<ul>) that contains images... sort of a thumbnail. I
want the images to display in center.
Here's a sample of my code:
In the future, post a URL instead. It's a lot easier for us to work with
than code snippets, plus snippets often do not provide all the necessary
info.
<ul class="nav_cd_imgs">
<li><a href="#"><img src="images/1.jpg" /></a></li>
<li><a href="#"><img src="images/2.jpg" /></a></li>
<li><a href="#"><img src="images/3.jpg" /></a></li>
</ul>
Simple, really. Don't float anything, or use display:block. That will
make those elements left-aligned. Just set text-align:center on the <ul>
and make the li's inline.
ul.nav_cd_imgs {
text-align: center;
list-style: none;
}
ul.nav_cd_imgs li {
display: inline;
}
Set margins and padding to taste on the ul, li and img as needed.
--
Berg
.
- References:
- Prev by Date: Re: Need help with float
- Next by Date: Re: Who wants to make me slap my forehead and go "D'OH!"???? (or "Unwanted Margins")
- Previous by thread: Re: How to center a list when display:block?
- Next by thread: Who wants to make me slap my forehead and go "D'OH!"???? (or "Unwanted Margins")
- Index(es):
Relevant Pages
|