Webkit 间距行为 - 由 Web Inspector 纠正
我在基于 Webkit 的浏览器中遇到了一个随机问题(在 Chrome 和 Safari 中测试)。在我维护的一个网站上,我一直在更新我们用于错误消息的插图,它在除基于 Webkit 的浏览器之外的所有浏览器中看起来都很棒。当我通过 Web 检查器打开或关闭任何 CSS 规则时,我遇到的问题似乎消失了。
问题:
文本大小控件上方的间距不应该存在,它应该如下所示:
烦人的是,当我在 Web Inspector 中切换任何 css 属性时,间距会消失。
弹出窗口的 HTML 为:
<div class="popup">
<div class="header">
<div class="block"></div>
<a class="normalFont" href="javascript:void(0);" title="Normal Font"><span>Normal Font</span></a>
<a class="largerFont" href="javascript:void(0);" title="Larger Font"><span>Larger Font</span></a>
<a class="largestFont" href="javascript:void(0);" title="Largest Font"><span>Largest Font</span></a>
<a class="close" href="javascript:void(0);" title="Close"><span>Close</span></a>
</div>
<div class="message">...</div>
<div class="footer"></div>
</div>
CSS 的关键部分为:
.popup
{
width: 310px;
}
.popup .header
{
height: 40px;
margin: 0;
padding: 0;
background: url(...);
}
.popup .header .block
{
float: left;
height: 19px;
width: 210px;
}
.block
应用到的位置:
有谁知道为什么会发生这种情况以及是否有解决方法?
更新:提供了一个实例(尽管使用过时的图形)此处。在 Webkit 浏览器中单击“医疗费用”等项目会显示带有间距错误的弹出窗口。
I've encountered a random issue in Webkit based browsers (tested in Chrome and Safari). On a website I maintain I've been updating the artwork we use for our error messages, and it looks great in all browsers except Webkit based browsers. The problem I am having seems to disappear when I toggle any CSS rule on or off through the Web Inspector.
The problem:
The spacing above the text-size controls shouldn't be there, it should look like:
The annoying thing is that the spacing disappears when I toggle any css property in Web Inspector.
The HTML for the popup is:
<div class="popup">
<div class="header">
<div class="block"></div>
<a class="normalFont" href="javascript:void(0);" title="Normal Font"><span>Normal Font</span></a>
<a class="largerFont" href="javascript:void(0);" title="Larger Font"><span>Larger Font</span></a>
<a class="largestFont" href="javascript:void(0);" title="Largest Font"><span>Largest Font</span></a>
<a class="close" href="javascript:void(0);" title="Close"><span>Close</span></a>
</div>
<div class="message">...</div>
<div class="footer"></div>
</div>
And the key part of the CSS is:
.popup
{
width: 310px;
}
.popup .header
{
height: 40px;
margin: 0;
padding: 0;
background: url(...);
}
.popup .header .block
{
float: left;
height: 19px;
width: 210px;
}
Where .block
is applied to:
Does anyone know why this occurs and if there is a workaround?
Update: A live example (although using outdated graphics) is available here. Clicking an item such as 'Medical Expenses' in a Webkit browser displays the popup with spacing error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是一个完整的答案,但希望它足以为您指明正确的方向。
在
Client.Popups.js
的CreateOverlay
函数中,如果我注释掉这一行:并将其替换为一些快速的 hacky 代码以制作覆盖层:
奇怪的差距是走了。
所以我的建议是仔细查看/重写覆盖代码。
This isn't a complete answer, but hopefully it's enough to point you in the right direction.
In
Client.Popups.js
, inside theCreateOverlay
function, if I comment out this line:and replace it with some quick hacky code to make an overlay:
The weird gap is gone.
So my suggestion is to look closely at/rewrite the overlay code.
这是由于浮动问题造成的,该问题似乎允许位于浮动元素上方的绝对位置元素影响元素在绝对定位元素内的流动方式。
This was due to a float issue that seemed to allow absolutely position elements sitting above the floated elements to affect how the elements was flowing within the absolutely positioned elements.