【问题标题】:Rotated text is breaking旋转的文字被破坏
【发布时间】:2013-06-21 18:59:05
【问题描述】:

我正在尝试使用Chris Coyier's CSS 将角丝带放在我的 div 上..

.ribbon-wrapper-green {
  width: 85px;
  height: 88px;
  overflow: hidden;
  position: absolute;
  top: -3px;
  right: -3px;
}

.ribbon-green {
  font-size: 10px;
  font-weight:bold;
  color: #111;
  text-align: center;
  text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg);
  position: relative;
  padding: 3px 0;
  left: -5px;
  top: 15px;
  width: 120px;
  background-color: #BFDC7A;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45)); 
  background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45); 
  color: #6a6340;
  -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
}

问题是,当文本变小并旋转时,文本似乎会中断。

这是小提琴:

http://jsfiddle.net/H6rQ6/8728/

如果它没有在您的浏览器中中断,这是我所面临的快照:

【问题讨论】:

标签: css


【解决方案1】:

您可以尝试强制浏览器刷新/重新计算使用字体样式播放的文本布局: http://jsfiddle.net/H6rQ6/8730/

.ribbon-green {
    font-weight: bold ;
    font-size:12px;
    font-family:Sans-Serif;
    color: #111; 
     font-variant: small-caps;
    font-size:120%;    /* other rules */
}

编辑,实际上,它只是与字体太小而无法流畅渲染有关。

问候

【讨论】:

    【解决方案2】:

    感谢showdev,我通过使用

    解决了这个问题
    -webkit-transform: rotate(45deg) translate3d( 0, 0, 0);
    

    这是因为字体在 chrome 中默认是抗锯齿的,而使用 translated3d(0,0,0) 会使它们变得平滑。

    更多:Wonky text anti-aliasing when rotating with webkit-transform in Chrome

    【讨论】:

      【解决方案3】:

      这完全是一个浏览器错误。你真的无法避免它。

      【讨论】:

      • 有什么文件可以备份吗?
      • 很公平,感谢您的检查。听起来确实像文本渲染的浏览器问题。奇怪的是我没有在 OP 使用的同一浏览器版本中看到它。我很好奇这是否已记录在案。
      • 至少对我来说,它取决于缩放级别。如果您放大和缩小,对于某些缩放级别,它会在另一个点中断,甚至根本不会中断。在 Canary 中显示相同,在 FF 中显示错误但不同
      猜你喜欢
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 2022-08-13
      • 1970-01-01
      • 2019-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多