【问题标题】:Chrome and Firefox CSS border issueChrome 和 Firefox CSS 边框问题
【发布时间】:2013-03-28 11:56:39
【问题描述】:

您好,我在 Firefox 和 Chrome 中显示边框时遇到了这个问题。它在 Safari 中看起来不错。

这里是小提琴/现场演示:http://jsfiddle.net/hirokotenshi/JhfS8/

Chrome 和 Firefox 中的那个看起来有点锯齿状。
这里: http://i923.photobucket.com/albums/ad77/Chapter-s/Screenshot2013-03-26at43905PM_zps5d62d1c9.png

我的 CSS:

#whatsnew {
  margin-top: 50px;
  border: 1px solid #D9D9D9;
  border-right: 50px solid #d52b1e;
  padding: 35px;
  -webkit-font-smoothing: antialiased;
      font-smoothing: antialiased;
  font-family: Verdana;
  padding-top: 20px;
  padding-bottom: 15px;
}

有人知道我该如何解决这个问题吗?

【问题讨论】:

  • 你有现场演示的链接吗?或者可以发一个fiddle
  • @Martyn0627 嘿,我没有现场演示,但我的帖子中有截图!
  • @Martyn0627 哦,我创造了一个小提琴jsfiddle.net/hirokotenshi/JhfS8

标签: css google-chrome firefox border


【解决方案1】:

这实际上是设计使然 - 边框在拐角处对角连接,因此您看到的是右边框的边缘逐渐变细以与其他 1px 边缘相接。

我能想到的最佳解决方案是使用包装 div,对其应用 1px 边框,然后在内部 div 中保留红色边框:

HTML:

<div id="wrapper">
<div id="whatsnew">
  <div id="whatsnewtitle">What's new?</div>
  <div id="whatsnewcon">
  <b>Do you know?</b><br />
  <br />
  Royal Dutch Shell plc filed its Annual Report on Form 20-F for the year ended December 31, 2012 with the U.S. Securities and Exchange Commission.
  <br />
  <br />
  <div style="text-align: right;">
  <a href=""><b>Find out more...</b></a>
  </div>

  </div>
</div>
</div>

CSS:

#wrapper {
border: 1px solid #D9D9D9;
margin-top: 50px;
-webkit-font-smoothing: antialiased;
    font-smoothing: antialiased;
font-family: Verdana;
}
#whatsnew {
border-right: 50px solid #d52b1e;
padding: 35px;
padding-top: 20px;
padding-bottom: 15px;
}

http://jsfiddle.net/JhfS8/1/

(快速而肮脏的黑客...)

如果您想避免包装器右侧的灰色边框,您也可以将其更改为红色:

    border-right-color: #d52b1e;

...如果你想变得真正聪明,你可以使用position: relative 和负边距将内部 div '拉'出边框,所以灰色消失在后面红色:

http://jsfiddle.net/JhfS8/2/

【讨论】:

  • 太棒了!有用!!非常感谢!!这个论坛太棒了谢谢!!
【解决方案2】:

尝试:-webkit-backface-visibility: hidden;-webkit-transform-style: preserve-3d; 或在 backface-visibility 之外添加一些填充

【讨论】:

  • 仍然没有帮助 :( 任何人都可以帮助我吗?这是一个相当大的项目.. 需要它看起来整洁!
猜你喜欢
  • 2015-04-04
  • 1970-01-01
  • 1970-01-01
  • 2011-11-08
  • 2011-05-29
  • 2021-09-07
  • 2012-01-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多