Reply to Re: Centering floating items

Your name:

Reply:


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/

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация