Jump to content

Recommended Posts

Posted

I'm wondering if anyone has any CSS-only methods of making a div of a fixed height appear vertically centered in the page. I've found methods that make it appear like this, but most of them use some sort of 25/50/25 rule (percentages here) to make the "middle section" appear in the center.

Any ideas?


Posted

How about something like this:

.mydiv{
background-color: black;
color: white;
position: fixed;
left: 10em;
top: 10em;
right: 10em;
bottom: 10em;
height: 100px;
}

To make its height fixed, i overrode the auto height adjustment with height: 100px. And if you change position to absolute instead of fixed, it will be like a normal div, else now it is fixed in the middle.

Posted

@n7epsilon - thanks for the reply, but it doesn't seem to work for me in Opera or IE7. I had thought of something like that, but sending conflicting information about an object usually ends up with strange cross-browser performance.

@ripken204 - nope... try it yourself.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...