CSS带背景的旋转文本显示了一些背景问题 [英] CSS rotated text with background shows some background-issues
问题描述
我正在使用CSS稍微旋转文本.文本在白色背景上是黑色的,但由于背景的旋转,因此有一些透明的小线穿过它.此图像将更清楚地显示它:
I am using CSS to slightly rotate Text. The text is black on a white background, but because of the rotation part of the background has some little transparent lines going through it.
This image will show it more clearly:
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解决方案.文本应该看起来像这样,在每行文本之间留有空格.
As this is a Wordpress site, I can't really adjust the HTML and tried to achieve the result with only CSS-changes. Therefore if possible I am looking for a CSS-solution that will fix the problem. The text should look exactly like this, with the spaces between each line of text.
推荐答案
添加小插入框阴影以避免出现此问题(似乎只能在Chrome上执行此工作)
Add a small inset box-shadow to avoid this issue (seems to do the job only on 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
另一个想法是考虑边界并依靠 box-decoration-break
(请注意支持:
Another idea is to consider border and rely on box-decoration-break
(pay attention to the support: 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
这篇关于CSS带背景的旋转文本显示了一些背景问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!