小编Sim*_*mor的帖子

文本后面的偏移块颜色

我正在寻找一种设置文本样式的方法,如下所示:

文本样式

我已经尝试过 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;
}
Run Code Online (Sandbox Code Playgroud)

关于做到这一点的最佳方法的想法?

html css text styles colors

3
推荐指数
1
解决办法
3654
查看次数

标签 统计

colors ×1

css ×1

html ×1

styles ×1

text ×1