Home > HTML/CSS > Ignoring TOP of Absolutely Placed DIV

Ignoring TOP of Absolutely Placed DIV

Here’s the scenario. You have a container DIV that is relatively placed. Inside the container you have an absolutely placed DIV and a static DIV. For some reason the TOP attribute of the absolutely placed DIV is ignored and it seems to inherit the TOP margin of the relatively placed DIV.

For some reason, if the container has a border, the attributes are rendered properly. Like a lot of you, I put a border on elements while I am developing to help with placement. So when I removed the border of the container the layout goes to crap.

One fix is to add:

<br clear=”all” />

right after the opening DIV for the container. This works but it causes FireFox and Safari to miscalculate the top margin of the relatively placed DIV.

I also added:

<br clear=”all” style=”margin:0; padding:0″ />

But that didn’t work.

I added 1px of padding to the top of the container DIV and that worked.

Categories: HTML/CSS
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.