Webkit 间距行为 - 由 Web Inspector 纠正

发布于 2024-10-10 03:24:57 字数 1804 浏览 4 评论 0原文

我在基于 Webkit 的浏览器中遇到了一个随机问题(在 Chrome 和 Safari 中测试)。在我维护的一个网站上,我一直在更新我们用于错误消息的插图,它在除基于 Webkit 的浏览器之外的所有浏览器中看起来都很棒。当我通过 Web 检查器打开或关闭任何 CSS 规则时,我遇到的问题似乎消失了。

问题:

Webkit CSS Bug?

文本大小控件上方的间距不应该存在,它应该如下所示:

Corrected

烦人的是,当我在 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 应用到的位置:

CSS 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:

Webkit CSS Bug?

The spacing above the text-size controls shouldn't be there, it should look like:

Corrected

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:

CSS Block

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长发绾君心 2024-10-17 03:24:57

这不是一个完整的答案,但希望它足以为您指明正确的方向。

Client.Popups.jsCreateOverlay 函数中,如果我注释掉这一行:

ResizeOverlay(offset.top, offset.left, width, height, target == null ? null : target);

并将其替换为一些快速的 hacky 代码以制作覆盖层:

$("body").append('<div style="position:absolute;top:0;width:' + $(document).width() + 'px;height:' + $(document).height() + 'px;background:red;opacity:0.5"></div>');

奇怪的差距是走了。

所以我的建议是仔细查看/重写覆盖代码。

This isn't a complete answer, but hopefully it's enough to point you in the right direction.

In Client.Popups.js, inside the CreateOverlay function, if I comment out this line:

ResizeOverlay(offset.top, offset.left, width, height, target == null ? null : target);

and replace it with some quick hacky code to make an overlay:

$("body").append('<div style="position:absolute;top:0;width:' + $(document).width() + 'px;height:' + $(document).height() + 'px;background:red;opacity:0.5"></div>');

The weird gap is gone.

So my suggestion is to look closely at/rewrite the overlay code.

动次打次papapa 2024-10-17 03:24:57

这是由于浮动问题造成的,该问题似乎允许位于浮动元素上方的绝对位置元素影响元素在绝对定位元素内的流动方式。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文