Internet Explorer 6 and 7: floated elements expand to 100% width when they contain a child element floated right. Is there a workaround?

后端 未结 8 943
滥情空心
滥情空心 2020-12-13 06:43

I\'ve got a parent div floated left, with two child divs that I need to float right.

The parent div should (if I understand th

8条回答
  •  轮回少年
    2020-12-13 07:16

    I couldn't come up with a CSS-only solution that fits your requirements, but if you want to use a JavaScript solution, maybe the following code can help? I did not alter the style of the divs, I only added the IDs main, sub1, and sub2 to your divs.

    var myWidth = document.getElementById('sub1').offsetWidth + document.getElementById('sub2').offsetWidth;
    document.getElementById('main').style.width = myWidth;
    

提交回复
热议问题