Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE CSS Float content specified width

Status
Not open for further replies.

Borvik

Programmer
Jan 2, 2002
1,392
US
I'm having a floating problem.

I'm attempting to have 2 divs side by side - so I used float on one to keep it to the right.

This floated div has more content I want side by side, but I want some of that take up say 70% of the available space within the main floated div.

Chrome, FireFox, Safari all display it correctly - but IE breaks it completely forcing the main two divs to stack.

Here is the code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL] 
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en"> 
<head> 
    <title>Example Page</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <style type="text/css">
    	.container{ width: 860px; margin: 0 auto; border: 1px solid black; }
    	.existing{ float: right; border: 1px solid red; }
    	.new{ border: 1px solid green; }
    </style>
</head>
<body>
<div class="container">
    <div class="existing">
        <div style="text-align: center;">Existing Users</div>
        <p style="white-space: nowrap;">Please enter your e-mail address and password, then click the Continue button.</p>
        <form action="?pg=login" method="post">
            <div>
                <div class="label" style="float: left;">E-mail</div>
                <div style="width: 70%; float: right;"><input type="text" id="txtEmail" name="login_email" size="20" value="" /><br /><span style="font-size: 11px;color: #333333;font-family: arial,helvetica,sans-serif;">(e.g. yourname@yourcompany.com)</span></div>
            </div>
        </form>
    </div>
    <div class="new">
        <div style="text-align: center;">New Users</div>
        <p>If you don't already have an account, click here:</p>
        <div><button type="button">Register</button></div>
    </div>
</div>
</body>
</html>

I originally used a table within the form, but it didn't work either, and this seemed better so...

Any ideas? (besides IE is a piece !@#*!@*#)
 
Adding widths to the floated container might help. Maybe IE expands it to fit the entire width of their container. Beyond that, it should work.

Could you tell us which IE (version) is causing the issue and which divs do not float correctly (I noticed you have two sets of divs that are floated).

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
I'm using IE7 on Vista.

The "existing" div is not floating correctly.

Adding a width to it - does allow it to float properly, but I was hoping that I could have it size to the unknown width of the no-wrap paragraph (unknown because of user chosen font-sizes).
 
Unfortunately, you will have to specify the width. IE ignores the fact that floated element should have an auto width (that is, to fit its content). Additionally, you also specify inside div to be 70%. 70% of what, if you don't even know the width of the container.

I think you should just specify the width of the container to be something a bit larger than the default font. And allow the font to break if it is too long.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Unfortunately I think your right.

As for 70% of what - 70% of the fit to content "existing" div - as determined by the no-wrapped paragraph - at least that's what I was hoping I could get accomplished.

I suppose it's not critical to have it no-wrap (I don't remember why I did it in the first place), so I'll pick some semi-arbitrary number about the same size and use that (stupid IE).

Thanks for looking into it at least.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top