|
Posted by rf on 11/27/23 11:30
sagejoshua wrote:
>>Using negative margins for centring is a Very Bad Mistake. If the viewport
>>is less than the width of the centred content then the content disappears
>>off the left hand of the viewport, never to be seen again. This content is
>>not accessible *at all*, the horizontal scroll bar will not let you to go
>>there.
>
> Hmm, you've got a very good point. I got the idea from "The Zen of CSS
> design." I guess you can't always trust what you read in books.
<grin/> How true.
>>To centre content use auto margins. For those browsers that do not support
>>it correctly (IE 5.x and IE6 in quirks mode) then use a suitable hack
>>(text-align: center;, hidden from other browsers, is one)
>
> How would I hide the text-align from other browsers. I know how to
> hide things from IE 5.x and below, but not the other way around.
Look into Conditional Comments (supported only by IE, search for it over at
http://microsoft.com ) although in this case you don't really need to hide
it from other browsers since you will need to set text-align: left for your
textual content anyway.
IE (<6 and quirks mode) has a bug where text-align: center not only
centres the actual content (the text) but any child element as well. You
could simply use it on the body element and set every other element
(including your "content container" back to left:
* {text-align: left;}
body {text-align: center: ...}
However, in your case I would question why you need the page to be exactly
this many pixels wide. All your visitors (except those few who have their
browser exactly the same size as yours) will have either a horizontal
scroll bar or wasted space in their viewport. What is wrong with using
width: 100% for your content?
--
Cheers
Richard.
[Back to original message]
|