Page 1 of 1

CSS Center Align

Posted: Sun May 15, 2011 9:13 pm
by Pazuzu156
Okay, here is the dilemma. I have this div element, an error. Well...a response. When the response is shown using jQuery, it will come from the top of the webpage, and disappear after 5 seconds. I have it at the top, but I want it to be dead in the center, but have it where when users with different screen resolutions can also see it in the center. Here is my CSS code for the entire thing:

Code: Select all

#response { 
    -moz-border-radius-bottomleft:6px;
    -moz-border-radius-bottomright:6px;
    -webkit-border-bottom-left-radius:6px;
    -webkit-border-bottom-right-radius:6px;
    width:220px; padding:5px;
    text-align:center;
    position:absolute;
    left:??;
    top:0;
}
Any help would be greatly appreciated.

Re: CSS Center Align

Posted: Mon May 16, 2011 5:05 am
by darek
You need to change jQuery code. Just get browser height, subtract your div height and divide result by two. That's how you get top position of your div. There's no css code that will align your div in center. You can't center your div the way you want, just by changing css.