Re: [css-d] Different ways of doing the same thing
Les, On May 25, 2007, at 11:30 AM, Les Mizzell wrote: It's always interesting to look at other folks stuff. I just inherited a site, and in looking at their CSS, the main div is listed thusly: #pageWrapper { width:760px; position:absolute; left:50%; margin-left:-380px; } Where I would have just done: #pageWrapper { width:760px; margin: 0 auto 0 auto; } Any advantage of doing it the first way? There is a major drawback to the first way. If the user's window is less than 760px wide, content will flow off the left edge of the window and become inaccessible. It the page has to be in quirks mode, or you need to support ie5/win, you can get the same result with body { text-align: center; } #pageWrapper { width: 760px; margin: 0 auto; text-align: left; } -- Roger Roelofs __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] Different ways of doing the same thing
Les Mizzell wrote: It's always interesting to look at other folks stuff. I just inherited a site, and in looking at their CSS, the main div is listed thusly: #pageWrapper { width:760px; position:absolute; left:50%; margin-left:-380px; } Where I would have just done: #pageWrapper { width:760px; margin: 0 auto 0 auto; } Any advantage of doing it the first way? __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/ Well, it won't confuse a browser that won't center with margin: auto (such as IE 7 in quirks mode). And for some reason they're taking the page out of the normal flow so maybe they had a reason for that? Other than that, I can suggest that you could also do it as: #pageWrapper { width: 760px; margin: 0 auto; } Which saves a few more bytes of data which means faster download times for your clients, sure not by much, but each optimization is still an improvement :) -- Thanks, Jim __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
[css-d] Different ways of doing the same thing
It's always interesting to look at other folks stuff. I just inherited a site, and in looking at their CSS, the main div is listed thusly: #pageWrapper { width:760px; position:absolute; left:50%; margin-left:-380px; } Where I would have just done: #pageWrapper { width:760px; margin: 0 auto 0 auto; } Any advantage of doing it the first way? __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] Different ways of doing the same thing
#pageWrapper { width:760px; position:absolute; left:50%; margin-left:-380px; } Where I would have just done: #pageWrapper { width:760px; margin: 0 auto 0 auto; } Without seeing the rest of the page or style sheet, my first guess would be they were attempting to center the div in IE5 and IE6 in quirks mode, which don't calculate the auto value for margins. Or if there was some other reason the wrapper needed to be removed from the normal flow by positioning it, if it needed to overlap other elements for example. But it's also just as likely that whoever authored that rule simply didn't know about margin: 0 auto; -- Craig, www.focalcurve.com __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] Different ways of doing the same thing
Hi Liz, I think the code you looked at centers the wrapper...,I'm not sure that your code does that. Ernie. From: Les Mizzell [EMAIL PROTECTED] To: css-d@lists.css-discuss.org Subject: [css-d] Different ways of doing the same thing Date: Fri, 25 May 2007 11:30:13 -0400 It's always interesting to look at other folks stuff. I just inherited a site, and in looking at their CSS, the main div is listed thusly: #pageWrapper { width:760px; position:absolute; left:50%; margin-left:-380px; } Where I would have just done: #pageWrapper { width:760px; margin: 0 auto 0 auto; } Any advantage of doing it the first way? __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/ _ Like the way Microsoft Office Outlook works? Youll love Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-usocid=TXT_TAGHM_migration_HM_mini_outlook_0507 __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/