2 回答
TA贡献1803条经验 获得超6个赞
下划线实际上是渐变背景。换行后它将被保留:
body {
background-color: #ccc;
}
span {
color: white;
font-size: 2em;
font-weight: bold;
background-image: linear-gradient(to bottom, transparent 50%, #7DE856 50%);
padding: .1em .4em;
-webkit-box-decoration-break: clone;
-o-box-decoration-break: clone;
box-decoration-break: clone;
}
<span>Sample Text</span>
<br>
<br>
<span>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Tempore necessitatibus obcaecati nisi quaerat! Provident eum ducimus impedit adipisci sequi.</span>
TA贡献1820条经验 获得超2个赞
::before在的帮助下CSS
.text {
position: relative;
padding: 1px 7px;
z-index: 1;
font-size: 20px;
line-height: 20px;
}
.text::before {
content: '';
position: absolute;
height: 40%;
width: 100%;
background: green;
opacity: 0.3;
bottom: 0;
left: 0;
z-index: 0;
}
<span class="text">text here</span>
<br>
<span class="text">sample text goes here</span>
<br>
<span class="text">text here</span>
- 2 回答
- 0 关注
- 92 浏览
添加回答
举报