CSS Centring in Mac
- Started
- Last post
- 8 Responses
- londonBoy
To centre content in a browser i've been using the follow css (for an object that is 400x400):
div#centred {
position:absolute;
left:50%;
top:50%;
margin-left:-200px;
margin-top:-200px;
}This works great on Windows but when viewed on Mac IE of Safari, the "top" attribute is completely ignored so half the content disappears above the browser's viewable area.
Does anyone have a fix for this?
- rasko40
minus 200?
- trooperbill0
body{text-align:center}
#stage{width:400px;text-align:le...content
- londonBoy0
The theory is that after first setting the left and top to position itself at 50% of the available screenwidth, it then takes half the object's width and height to position it centrally.
- welded0
You will end up having to toss out the DOCTYPE declaration. This has been my experience.
- londonBoy0
I suspect you're right welded. I'm currently working through this journal entry from hicksdesign http://www.hicksdesign.co.uk/jou… which may help.
- moth0
um...
margin-right: auto;
margin-left: auto;That should do it. If you want no top margin - set it to 0 in the body.
- moth0
- shaft0
Does this work on a Mac?
http://www.who.vectranet.pl/~elu…