开发者

Webkit spacing behaviour - corrected by Web Inspector

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 spacing behaviour - corrected by Web Inspector

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

Webkit spacing behaviour - corrected by Web Inspector

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:

Webkit spacing behaviour - corrected by Web Inspector

D开发者_开发百科oes 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜