Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Centre list items

Centre list items


Is it possible to Centre list items on a page using CSS? I have a long dynamic list of images that repeat in the following fashion:

Each image is 120px wide with 5px padding. The list will be displayed on a variety of mobile devices with different screen widths, so the list will wrap in most cases. I would like the images to be centre aligned on the page but I'm not sure how to go about this. Does anyone have any ideas?

Problem Courtesy of: Dancer


.imgSelec ul li {
    width: 130px;
    margin: auto;

Note: MUST set a width to then use margin: auto to center elements.

Solution courtesy of: Rick Donohoe


View additional discussion.

This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Centre list items


Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription