我有<span>
带有一些文字。这个跨度有 background
属性,我想这个背景将覆盖文本。这是我的代码:
span {
background-image: -moz-linear-gradient(left, rgba(255,0,0,1) 0%, rgba(255,17,0,1) 100%);
background-image: -webkit-linear-gradient(left, rgba(255,0,0,1) 0%, rgba(255,17,0,1) 100%);
background-image: -o-linear-gradient(left, rgba(255,0,0,1) 0%, rgba(255,17,0,1) 100%);
background-image: -ms-linear-gradient(left, rgba(255,0,0,1) 0%, rgba(255,17,0,1) 100%);
background-image: linear-gradient(to right, rgba(255,0,0,1) 0%, rgba(255,17,0,1) 100%);
background-size: 4px 6px;
background-repeat: repeat-x;
background-position: 0 .55em;
color: green;
font-size: 24pt;
}
<span>SomeTextSomeText</span>
我想要得到:
不改变background
属性,使用伪元素( ::after
、 ::before
)或添加新元素。是否可以?感谢您的帮助。
最佳答案
为什么不使用text-decoration
属性?
span {
text-decoration: line-through red;
color: green;
font-size: 24pt;
}
<span>SomeTextSomeText</span>
关于html - CSS - 文本背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48504033/