Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Relative Vertical Alignment


Guest

Recommended Posts

Posted

This isn't actually for an osCommerce site, but I'm trying to vertically center a box using relative positioning so that it moves when you resize the browser. I also want it to stop when it reaches the top of the page, but I can't seem to figure that part out.

Here's the <style> section of the code. It's for a <div> I will call "flash_box".

 

<style type="text/css">

<!--

body, html {

height:100%; /*fill the viewport*/

}

#flash_box{

position:relative; /*allows for top property to move the element*/

top:50%; /*moves it 50% of #container's height down the page*/

margin-top:-400px; /*pulls it back up by half it's height*/

margin-left: auto;margin-right: auto; /*H-centering in complaint browsers*/

}

 

-->

</style>

Archived

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

×
×
  • Create New...