开发者

Position: Absolute and Position: relative Problem in ie

开发者 https://www.devze.com 2023-02-17 18:01 出处:网络
I have a problem. See the code below please. <div style=\"position:relative; overflow:hidden; width:120px;\">

I have a problem. See the code below please.

<div style="position:relative; overflow:hidden; width:120px;">
  <div style="position:absolute; left:0px;">Content</div>
  <div style="position:absolute; left:40px;">Content</div>
  <div style="position:absolute; left:80px;">Content</div>
</div>

The problem is, that in firefox, its working fine; but when i run this code in ie-8, it gives problem. All the divs with position:absolute are 40px wide. they should just simply attain开发者_如何学Go the position i assign them to. In ie, the 2nd div with position:absolute take double left-space. It counts the first div to be of 40px and then counts 40px more. It should just take 40px from the relatively positioned div's left side. Can somebody help please?


It works as expected in ie7 & ie8. And drop that overflow: hidden, because it hides everything. Look here how it all looks with border: http://jsfiddle.net/uWkJ7/1/ All divs expand to their content width.


In “non-layout” elements, hasLayout is not triggered, i.e. a pure div without a dimension can be a “non-layout ancestor”.

0

精彩评论

暂无评论...
验证码 换一张
取 消