Sign in to follow this  
iaminternets

I have a very basic CSS question! :]

Recommended Posts

iaminternets    187
<html>
  <body>
    <div style="background-color:red;position:absolute;width:400px;top:50%">
      [non-breaking-space]
      <div style="background-color:blue;width:50px;position:relative;top:-50%;">
        [non-breaking-space]          
      </div>
      [non-breaking-space]
    </div>
  </body>
</html>





Aparently, in Firefox, if an element isn't absolute:positioned, you can't use percentage units with the top property. It's frustrating! I'm trying to vertically center images (yes, the above code is incomplete, but it demonstrates my point about percentage units); is there a work-around? EDIT: I'm sorry for the initial post; I wasn't quite sure how I was supposed to post HTML! [Edited by - iaminternets on October 24, 2008 9:52:39 PM]

Share this post


Link to post
Share on other sites
iaminternets    187
Thanks for the reply! ++rep

I'll probably just end up using the solution that article provided, but why won't 'top' accept a percentage value if the element isn't absolutely positioned?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this