|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Lackey to Felines
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2007
Posts: 1,355
|
Centering an entire page
I've spent some time doing another freebie design for a nonprofit organization, this one a local animal rescue outfit with a truly awful site of their own. Here's the link to the demo. (Yes, their logo's ineffably cheesy, but their dogs can handle Photoshop with about the same skill as I have, so the logo stays unless someone wants to donate one.
)I looked at the site demo on a much larger display than I normally have access to, and was not pleased to see that it doesn't center, but lines up on the left. Of course it does, I didn't tell it to do otherwise. My question is, what's an easy and (relatively) painless way to go back and center it? I'm familiar with the classic method from Dan Cederholm and others, but, perhaps because I'm not using a fixed layout, it doesn't work. Or I did something stoopid and it didn't work, always a possibility. I know it's a duh! question with a simple answer, but hey, how do I learn if I don't ask the dumb questions? ![]() |
|
|
|
|
|
#2 |
|
Unobtrusively zen
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2007
Location: Christchurch
Posts: 4,988
|
Setting the left/right body margin to auto should do the trick
css Code:
|
|
|
|
|
|
#3 |
|
Lackey to Felines
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2007
Posts: 1,355
|
Paul, I thought that was too simple to actually work!
![]() Edit: it works perfectly, of course. I was thinking less of Occam's Razor and more of Murphy's Law. |
|
|
|
|
|
#4 |
|
Unobtrusively zen
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2007
Location: Christchurch
Posts: 4,988
|
It does seem though that the slugline is falling off to the side. This is because it's position is set as an absolute, which is in terms of the next higher up relatively positioned element.
As there is no parent element that is set to relative, the slugline is positioned according to the window itself. You'll want to set the header to be the relative reference for positions within it. This doesn't affect the header itself, but it does mean that the slugline will be positioned relative to the header instead, properly as it should be. css Code:
|
|
|
|
|
|
#5 |
|
CSS Guru in Training
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2008
Location: Whiteford, MD
Posts: 8,691
|
Hi, you should avoid auto margins on the body as IE7< have several bugs related to that.
You should instead make a wrapper div enclosing the entire page and give a width and auto margins to that instead . |
|
|
|
|
|
#6 | |
|
Unobtrusively zen
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2007
Location: Christchurch
Posts: 4,988
|
Quote:
http://my-debugbar.com/wiki/IETester/HomePage |
|
|
|
|
|
|
#7 | |
|
SitePoint Mentor
![]() Join Date: May 2007
Location: Countryside, Sweden
Posts: 2,976
|
Quote:
![]() Code:
#header,
.colmask,
#footer {
float: none;
margin: 0 auto;
min-width: 600px;
max-width: 1200px;
}
|
|
|
|
|
|
|
#8 | ||
|
Lackey to Felines
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2007
Posts: 1,355
|
Quote:
Quote:
Ryan, thanks for your suggestion. I'm assuming that Erik's solution won't cause hiccups in IE6 and 7...? |
||
|
|
|
|
|
#10 |
|
Lackey to Felines
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2007
Posts: 1,355
|
Can't install IETester because my Windows setup is old, creaky, and not quite kosher.
![]() I'm running it through Browsershots now, and so far everything looks good. Edit: There are minor issues with its display in IE6, but I just don't care. ![]() |
|
|
|
|
|
#11 |
|
CSS Guru in Training
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2008
Location: Whiteford, MD
Posts: 8,691
|
It won't cause too many issues other then it not understanding min/max width
.. |
|
|
|
|
|
#12 |
|
Lackey to Felines
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2007
Posts: 1,355
|
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 03:59.




)

it works perfectly, of course. I was thinking less of Occam's Razor and more of Murphy's Law.
.





Hybrid Mode
