开发者

Using absolutely positioned element inside inline-block element in Opera

开发者 https://www.devze.com 2023-01-08 01:10 出处:网络
I keep getting weird results under Opera 10.60 trying to absolutely positio开发者_JAVA技巧n block element inside inline-block element.

I keep getting weird results under Opera 10.60 trying to absolutely positio开发者_JAVA技巧n block element inside inline-block element.

Sample code:

<html><head><style type="text/css">
div.container {
    position: relative;
    display: inline-block;
    padding: 5px 100px;
    border: 1px solid red; 
}
div.block {
    display: block; 
    position: absolute; 
    top: 0px; 
    right: 0px; 
    border: 2px solid brown;
}
</style></head><body>

<div class="container">
  <div class="block">(>O.o)></div>
  Quick brown block <a href="#">jumps</a> over relative div. 
</div>

</body></html>

Opera positions .block relative to the last inline element ( in this example) inside the same parent (.container), instead of positioning it relative to the parent.

Am I missing something, or is it just a bug, and I should find the other way around?


wrap your content in a div or something else, then it works. http://jsbin.com/isuke3/edit


Change position: relative; to position: absolute;

and it will align itself correctly in the browsers. :)

0

精彩评论

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