Posted by Nico Schuyt on 10/18/06 17:26
Ben C wrote:
> Don't use floats. You can give a float a left margin, but you will
> have
> to work out how big to make it yourself to achieve centering (don't go
> there). Absolute positioning is much better for this because the
> browser
> will centre it for you if you set left and right margins to auto
> (provided you also set left, right and width).
> Here is an example:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/REC-html40/strict.dtd"> <html>
> <head>
> <title>Test Page</title>
> <style type="text/css">
> ul
> {
> position: absolute;
> left: 0px;
> right: 0px;
> width: 100px;
> margin-left: auto;
> margin-right: auto;
> padding: 0px;
> }
> li
> {
> list-style-type: none;
> border: 1px solid black;
> }
> </style>
> </head>
> <body>
> <ul>
> <li>apples</li>
> <li>pears</li>
> <li>oranges</li>
> </ul>
> </body>
> </html>
In IE there΄s a vertical list on the left
In FF the (vertical) list is centered on the page
--
Nico Schuyt
http://www.nicoschuyt.nl/
Navigation:
[Reply to this message]
|