Forum Moderators: not2easy

Message Too Old, No Replies

Should be easy (but apparently isn't. . .)

Problem with positioning of right-floated element in IE6

         

bkinsey1

8:51 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



I've hacked together a fairly substantial site using all CSS for positioning, but I'm not an expert by any means. So, I'm playing with various layouts, and ran across a problem that I haven't been able to find an answer for, because I don't know what I'm really looking at. . . .

The layout I'm looking for is fairly simple: header div with image at left and right-floated company info; content div, enclosing main div and right-floated right rail; and a footer, with nav buttons to the left and a copyright statement at the right.

It all works except for the copyright, which is positioned only with float:right. It's container divs are not positioned at all. It displays correctly in Opera 7.2, but IE 6 puts the copyright only about 2/3 of the way across the page, instead of all the way right. Haven't tested (yet) in any other browsers.

IE has numerous bugs, of course, but is this a bug, or am I just missing something?

Page, with CSS, is available here: <snip>

Any help is appreciated. Thanks.

[edited by: DrDoc at 9:08 pm (utc) on April 28, 2004]
[edit reason] No URLs, thanks. See TOS [webmasterworld.com] [/edit]

D_Blackwell

9:29 pm on Apr 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Post just enough of the HTLM and CSS to replicate the problem.

You might find the fix just from the process of doing this. It almost always comes down to commenting bits and pieces of code in and out, until you zero in on the trigger of the problem.

Few of my problems are bugs. They are usually self inflicted wounds.

aeve

9:29 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



Have you declared a width on the floated copyright statement? And if so, does it have a declared right margin?

It sounds like the ie double margin bug -- if something is floated and has a margin in the same direction, internet explorer mysteriously doubles it. Supposedly it can be fixed with no cross-browser problems by declaring

display: inline
on the floated element. There's more information at "position is everything".

Adam

bkinsey1

9:42 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



Here's the relevant code: (as I said, it's pretty bare bone).

#top {height: 200px;
background: white;}
#address {float:right;
font:bold italic 130% helvetica;
padding:0px 20px 0px 0px;}
#address:first-line {font-size:150%;}
#content {border: 1px solid blue;}
#main {background:#fff;
border:1px solid #000;
margin-right:220px;}
#rightrail {border-left:1px solid #000;
border-bottom:1px solid #000;
float:right;
clear:none;
width:220px;
background:#eee;
margin:0px 0px 10px 10px;}
#footnav {background:black;
margin-top:5px;
padding:5px 5px 5px 25px;
font: 60% helvetica;}
#footnav .button {color:white;
font-weight:bold;
display:inline;
margin:0px 10px 0px 10px;
border:1px dashed white;}
#copyright {color:white;
font-weight:bold;
float:right;
margin:0px 10px 0px 10px;
border:1px dashed white;}
</style>
</head>
<body>
<div id="top">
<p id="address">Name<br />
Street Address<br />
City, State, Zip<br />
Phone Number</p>
<img src="images/red.jpg" width="200" height="200" />
</div> <!-- end "top" -->
<div id="content">
<div id="rightrail">
Right<br />
Right<br />
Right<br />
Right<br />
Right<br />
Right<br />
Right<br />
</div> <!-- end "rightrail" -->
<div id="main">
Main<br />
Main<br />
Main<br />
Main<br />
Main<br />
Main<br />
Main<br />
</div> <!-- end "main" -->
<div id="footnav">
<div id="copyright">Copyright 2004, Business Name</div>
<div class="button">Foot</div>
<div class="button">Foot</div>
<div class="button">Foot</div>
</div> <!-- end "footnav" -->
</div> <!-- end "content" -->

I have seen the double-margin bug; but this doesn't look like it; the right margin on the copyright float is only 10px, and it's offset by over 200. . .

BTW, the doctype is xhtml strict, and the xmlns is included in the full page (just clipped out to save posting space), and the page validates, aside from a missing alt tag and type declaration on the style statement.

I'm half expecting a "self-inflicted wound" :-), but I sure don't see it at this point. Thanks, guys. . .

MsDetta

9:54 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



#footnav {background:black;
margin-top:5px;
padding:5px 5px 5px 25px;
font: 60% helvetica;}

#copyright {color:white;
font-weight:bold;
float:right;
margin:0px 10px 0px 10px;
border:1px dashed white;}

You've got the copyright nested inside of the footnav, so it's picking up the padding.

you could try adding this to the copyright:
padding: 0px!important;

D_Blackwell

9:59 pm on Apr 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't tested it out yet, but this appears to fix it.

Add {clear: right;} to #copyright.

bkinsey1

10:02 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



True, but that only totals 15px, which is what I want (and how is displays in Opera). IE is scooting it over by more than 200px!

bkinsey1

10:08 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



Ah, thank you. {clear:right} did the trick. The question now, I suppose, is why? There's nothing floated to the right for it to clear. . . .

D_Blackwell

10:23 pm on Apr 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looking more closely, I believe that I would put the {clear: right} with #footnav instead, and adjust {margin-top} if necessary.

You are clearing the float from #rightrail. Looking like an IE thing, which may mean bug after all.

aeve

11:38 pm on Apr 28, 2004 (gmt 0)

10+ Year Member



The copyright isn't clearing the 10px bottom margin of the rightrail -- if you change:

#rightrail {border-left:1px solid #000;
border-bottom:1px solid #000;
float:right;
clear:none;
width:220px;
background:#eee;
margin:0px 0px [b]0px[/b] 10px;}

it should (also) fix the problem.

Adam

D_Blackwell

1:03 am on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



aeve - Interesting catch. It does also fix the problem (and does it better), although it will break again if any more content is added to the #rightrail, and then the {clear: right;} will again be needed. The bigger issue, now that the problem is isolated, may be what the final content is, and if it breaks the intended layout.

vkaryl

1:54 am on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The bigger issue, now that the problem is isolated, may be what the final content is, and if it breaks the intended layout.

If the content is not subject to frequent rewrite-and-associated-expansion, this should work just fine. If there's a lot of change in this portion of the page layout....

Hmmm. The fix I was going to post doesn't work in all browsers.... Not that that's unusual.... *sigh*....

bkinsey1

3:10 am on Apr 29, 2004 (gmt 0)

10+ Year Member



It's good to have experts, guys. Thank you; I see the problem now. I was thinking rightrail should be completely enclosed by main, and thus couldn't interfere with anything below the main div. But rightrail is floated, meaning it will overflow the boundaries of main w/ enough content. . . . Given that realization, and since it does it in IE and not Opera, I'm thinking it may just be a box-model issue with the size of rightrail, and I could solve it with the standard box model hack, and keep my margins (if I need them). Or I may look at declaring height for main and rightrail, and making sure the rightrail content stays within bounds.

I'll try one or both tomorrow. For now, no more work. . . :-)