Webkit spacing behaviour - corrected by Web Inspec

2019-07-15 15:13发布

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.

2条回答
相关推荐>>
2楼-- · 2019-07-15 15:38

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.

查看更多
趁早两清
3楼-- · 2019-07-15 15:50

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.

查看更多
登录 后发表回答