Forum Moderators: not2easy

Message Too Old, No Replies

H2 overlapping with my Div

h2 is extending under my div

         

jzeil

8:04 pm on Sep 4, 2007 (gmt 0)

10+ Year Member



I'm having a problem with a CSS layout. Code below.

I want the H2 to behave like the HR is. Right now the H2 goes under the adSpace element. How can I make the H2 stop at the side of the adSpace?

The adSpace div may or may not be in the document. So I cant have a solution that assumes its there (like putting a margin of 160 on the h2).

Why is the Red extending through the other element?

Thanks


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head></head>
<body>

<div id="adSpace" style="display:block;float:right;width: 160px; height: 500px; border: 1px solid green;">
Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here.
Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here.
Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here.
Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here. Ad goes here.
</div>

<h2 style="border: 1px solid blue; background: #9A2A3A;">
This is a title
</h2>

<hr/>

</body>

</html>

Marshall

8:10 pm on Sep 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How can I make the H2 stop at the side of the adSpace?

What exactly do you mean by this? You can insert the <h2> in its own <div>.

Marshall

zsoly

11:42 am on Sep 5, 2007 (gmt 0)

10+ Year Member



Hi jzell,

You need to add "overflow: hidden;" to H2 style...
Like this:
<h2 style="border: 1px solid blue; background: #9A2A3A; overflow: hidden;">
This is a title
</h2>

For IE compatibility you would need to add: "height: 1%;" to activate has_layout.

Hope this helps.

Zsolt.