salmane
salmane

Reputation: 4849

IE DIV with absolute positioning width goes to 100% of screen when it has a floating element inside

I have created a dialog box ( a div with position:absolute) if any element inside the box has a float : right the width of the box goes to 100% of the screen in IE7

float :left does not affect it. this problem is specific to ie7

thank you for your help

Upvotes: 3

Views: 3711

Answers (2)

dima.rus
dima.rus

Reputation: 182

Instead of float:right; on the inner block, you can use text-align:right; on the parent block. See example:

<div style="position:absolute; text-align:right;">
    <div style="float:left;">
        123
    </div>
    <div>
        456
    </div>
</div>

It looks like this: http://jsfiddle.net/XLnYJ/49/

Tested on: ie 6 & 7; firefox; opera; gchrome.

Upvotes: 2

S16
S16

Reputation: 2995

You absolutely have to set the width of an absolutely positioned element if it contains an element floated right to get it to behave properly.

Upvotes: 3

Related Questions