开发者

How to left align list items when unordered list is centered on the page?

开发者 https://www.devze.com 2022-12-31 04:03 出处:网络
I have a div that holds an unordered list with several list items. I am using ie6 and am basically trying to center the unordered list on the screen but at the same time want the actual list item text

I have a div that holds an unordered list with several list items. I am using ie6 and am basically trying to center the unordered list on the screen but at the same time want the actual list item text aligned to the left.

At the moment, I have my unordered list within the cent开发者_JS百科er tags, which has centered the list but I would actually like to now left align the actual list item text.

Why am I unable to left the align the text now?


You need to center the containing div, not the entire document.

div#theID {
    margin: 0 auto; /* auto margins will center */
    width: 200px; /* needs a set width, for auto-margins */
}

In case IE 6 doesn't like this, you can add a fix like this

body {
    text-align: center;
}

div#theId {
    text-align: left;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消