【发布时间】:2018-05-02 18:02:20
【问题描述】:
我正在寻找一种方法来设置这样的文本样式:
我已经尝试过 h2::before 伪类,但是它将样式添加到整个 h2 元素而不是文本,因此不会在 多行上设置样式。
h2{
font-size: 48px;
color: black;
font-family: 'Roboto', sans-serif;
font-weight: 900;
line-height: 0.9;
}
h2::before {
content: "";
position: absolute;
width: 100%;
height: 10%;
top: 21px;
left: -10px;
background: rgba(229, 57, 53, 100);
z-index: -1;
}
想到了最好的方法吗?
【问题讨论】:
标签: html css text colors styles