Opera 11 中浮动时元素宽度的计算。*
我正在处理 Opera 11.5 beta 中的一个问题(我假设这与所有 Opera 11 版本相关),其中浮动的块级元素(无序列表)被赋予任意固定宽度并导致要换行的子元素 - 与 IE6 的方式相同。
该元素向右浮动并且当前没有兄弟元素。我的样式表中没有为列表指定宽度。
我想知道 Opera 在这些情况下使用什么样的逻辑来计算宽度?
我上传了一张比较 Opera 11.5 和 Firefox 4.1 以及 Dragonfly/Firebug 输出的图像。
I'm dealing with an issue in the Opera 11.5 beta (I am presuming this is relevant to all Opera 11 releases) whereby a floated, block-level element (an un-ordered list) is being given an arbitrary fixed width and causing the child elements to wrap - in the same way to IE6 does.
The element is floated right and currently has no siblings. There are no widths specified for lists in my stylesheet.
I was wondering what sort of logic Opera uses to calculate width in these instances?
I have uploaded an image comparing Opera 11.5 to Firefox 4.1 with Dragonfly/Firebug output.
http://twitpic.com/55f79o/full
jsFiddle: http://jsfiddle.net/i_like_robots/HKAQ9/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还不知道为什么(稍后会看到),
但 Opera 不喜欢没有宽度的
replace
类,我认为该类(按其名称)是用来容纳替换背景图像的,那么在上面加一个宽度应该可以吗?
更新了它连接到文本隐藏的
text-indent
方法 - 没有文本缩进它在Opera中也很好I don't know why yet (will look later)
but Opera is not liking the
replace
class not having a width on itI presume that class(by it's name) is to house a replacement background image, so it should be OK to put a width on it?
Updated it is connected to the
text-indent
method of text hiding - without the text indent it is also fine in Opera据我所知,这是 Opera 中的一个错误。
计算元素的宽度时,它会根据子元素的所有宽度的总和进行计算,但如果您有 2 个 Div 元素作为子元素,显示为块元素,则实际上宽度不是两个元素的总和。
要解决这个问题,您所要做的就是指定父元素的宽度,而不是让 Opera 进行计算。
@clairesuzy - 您可以使用我在此处发布的代码http: //www.go4expert.com/forums/showthread.php?t=27000
According to me it is a bug in Opera.
When calculating the width of an element it calculates based on the sum total of all the width of child elements but if you have 2 Div elements as child displaying as block elements actually the width is not sum total of both the elements.
To fix the issue all you have to do is specify the width of the parent element instead of allowing Opera to calculate.
@clairesuzy - You can see the bug in action with the code I have posted here http://www.go4expert.com/forums/showthread.php?t=27000