html - 带有背景的 CSS 旋转文本显示了一些背景问题

标签 html css rotation css-transforms

我正在使用 CSS 稍微旋转文本。文本在白色背景上是黑色的,但由于背景的旋转部分有一些透明的小线条穿过它。 此图像将更清楚地显示它:
My issue

body {
  background: red;
}

.featured-grid-b .item-heading {
  /*Black text on white background*/
  box-shadow: 0 0 0 5px #fff;
  padding: 0;
  background: #fff;
  line-height: 2 !important;
  display: inline;
  color: #000;
  text-shadow: none;
}

.caption h3 {
  /*Rotate Text*/
  transform: rotate(-3deg);
  margin-bottom: 15px;
}
<div class="featured-grid featured-grid-b" data-animation="fade" data-animation-speed="600" data-slide-delay="5000">
  <div class="caption caption-large">
    <h3><a href="http://www.fair-fashion-magazin.de/2019/07/03/das-nachhaltige-mode-label-people-tree/" class="item-heading">Fashion zum Verlieben: Das Fair Fashion Label People Tree</a></h3>
  </div>
</div>

由于这是一个 Wordpress 网站,我无法真正调整 HTML 并尝试仅通过更改 CSS 来实现结果。因此,如果可能的话,我正在寻找可以解决问题的 CSS 解决方案。 文本应该看起来完全像这样,每行文本之间都有空格。

最佳答案

添加一个小的内嵌框阴影来避免这个问题(似乎只在 Chrome 上做这个工作)

.item-heading { 
    /*Black text on white background*/
    box-shadow:
      0 0 0 5px #fff,
      0 0 0 2px #fff inset;
    padding: 0;
    background: #fff;
    line-height: 2 !important;
    display: inline;
    color: #000;
    text-shadow: none;
}

.caption h3 {
    /*Rotate Text*/
    transform: rotate(-3deg);
    margin-bottom:15px;
}

body {
 background:pink;
}
<div class="caption caption-large">                                     
<h3><a href="http://www.fair-fashion-magazin.de/2019/07/03/das-nachhaltige-mode-label-people-tree/" class="item-heading">Fashion zum Verlieben:<br> Das Fair Fashion Label People Tree</a></h3>
</div

另一种思路是考虑border,依赖box-decoration-break(注意支持:https://caniuse.com/#feat=css-boxdecorationbreak)

.item-heading { 
    /*Black text on white background*/
    border:5px solid #fff;
    padding: 0;
    background: #fff;
    line-height: 2 !important;
    display: inline;
    color: #000;
    text-shadow: none; 
    -webkit-box-decoration-break: clone;
     box-decoration-break: clone; 
}

.caption h3 {
    /*Rotate Text*/
    transform: rotate(-3deg);
    margin-bottom:15px;
}

body {
 background:pink;
}
<div class="caption caption-large">                                     
<h3><a href="http://www.fair-fashion-magazin.de/2019/07/03/das-nachhaltige-mode-label-people-tree/" class="item-heading">Fashion zum Verlieben: <br>Das Fair Fashion Label People Tree</a></h3>
</div

关于html - 带有背景的 CSS 旋转文本显示了一些背景问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57094587/

相关文章:

javascript - Bootstrap toast 移动所有元素

javascript - jQuery Carousel 插件显示不需要的边框

java - Java 拖动鼠标旋转缩放

html - 在表中旋转标题时出现格式错误

java - 绕特定点旋转(例如,绕0,0,0旋转)

css - 字体在 chrome 中的 HTML5 验证中更改

html - 网站帮助 - 创建更好的 ChatRoulette

html - 在 ngRepeat 和 Foundation 框架中使用 ngClass

使用return false时,javascript确认(取消)仍然提交表单?

html - 在 PX 和百分位之间选择