Jump to content

centering


acidglitter

Recommended Posts

position:absolute is exactly that - no more no less - YOU tell it where to go regardless of the window ... it does not adjust with the rest of the page because position:absolute is OUTSIDE of the flow of your code markup flow..

 

Lose position:absolute. It is not a good layout tool.

 

Don't float or use "position", just give the div a width less than its container and use "margin: 0 auto"

Link to comment
https://forums.phpfreaks.com/topic/109179-centering/#findComment-560167
Share on other sites

That will just make a mess of anything else on the page because position:absolute is greedy and ignores everything else.

 

Until you are an expert at css (not just "good enough", I'm talkin' you know it all cold) avoid position:absolute like the plague. It is NOT a "friendly" layout element and does NOT play well with others.

Link to comment
https://forums.phpfreaks.com/topic/109179-centering/#findComment-562809
Share on other sites

well i don't want this div to have anything to do with the rest of the page. its a temporary div that i want to show up in the middle of the screen, no matter if you're at the top of the page or have scrolled down to the middle.. so i was just setting the position to absolute, then the top position to a certain amount of pixels plus however many pixels away from the top of the page.. i guess instead of top it would work the same to set that to margin-top and then the other margins to auto (and then a high z-index)...

Link to comment
https://forums.phpfreaks.com/topic/109179-centering/#findComment-563274
Share on other sites

i guess instead of top it would work the same to set that to margin-top and then the other margins to auto (and then a high z-index)...

 

As simple as that.

 

You don't even need the z-index if it isn't being "absolute-positioned".

 

#div
{
    margin:25% auto 0 auto;
    width: 200px;
    height: 200px;
}

Link to comment
https://forums.phpfreaks.com/topic/109179-centering/#findComment-563403
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.