Forum Moderators: not2easy
The following code shows the problem.
<div style="float: right; border: solid 2px red;">
this is an ad<br>or something like that
</div><div style="width: 34em; text-align: left; margin: 0 auto;">
<h1 style="text-align: center;">This is the page heading</h1><p>
This is the main body of text, which I want to be a column of text 34em wide, centered on the page. Blah, blah, blah, blah, blah, blah.</div>
Is there any straightforward way to fix this? -- I want the appearance in IE to be like the appearance in FF.
<div style="position: absolute; top: 0; right:0; border: solid 2px red;">
this is an ad<br>or something like that
</div>
<div style="width: 34em; position:absolute; left: 50%;margin-left:-17em;">
<h1 style="text-align: center;">This is the page heading</h1>
<p style="text-align:left;">
This is the main body of text, which I want to be a column of text 34em wide, centered on the page. Blah, blah, blah, blah, blah, blah.
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
<div style="float: right; border: solid 2px red;">
this is an ad<br>or something like that
</div>
<div style="width: 34em; text-align: left; margin: 0 auto;">
<h1 style="text-align: center;">This is the page heading</h1>
<p>This is the main body of text, which I want to be a column of text 34em wide, centered on the page. Blah, blah, blah, blah, blah, blah.</p>
</div>
</body>
</html>
Notice that I always wrap my examples in valid DOCTYPE tags. This can make a HUGE difference in exactly the type of issue that you are having.
<div style="width: 34em; text-align: left; margin: 0 auto;"><div style="width: 120px; float: right; margin-right: -120px; border: solid 2px red;">this is an ad or something like that</div>
<h1 style="text-align: center;">This is the page heading</h1>
<p>This is the main body of text, the exact layout can be negotiated,
but it must also be well-formed and grammatical, and must not consist
of artificial strings of keywords. </p>
</div>
I just did some checking and the negative-margin solution (with the adbox *inside* the centre column) works in IE7. It fails badly in IE6, though, so that's not an option unless there's a fix.