[英]How to display mutiple underline color by css (instead of one color)
You can make a pseudo element by using :after
您可以使用
:after
创建一个伪元素
span { text-decoration: underline; text-decoration-color: red; text-decoration-thickness: 2px; position: relative; } span::after { content: ""; width: 100%; display: block; position: absolute; height: 4px; background: orange; bottom: -6px; border-radius: 10px; }
<p> <span>Text-decoration</span> is to set underline color. </p>
This is a solution for having multiple borders using box-shadow
and text-decoration
at the same time.这是一种同时使用
box-shadow
和text-decoration
来拥有多个边框的解决方案。 The regular border was added as the first underline crossing the font baseline with an offset defined by text-underline-offset
常规边框被添加为与字体基线交叉的第一个下划线,其偏移量由
text-underline-offset
定义
.paragraph{ font-size: 20px; font-family: arial; color: #2C019D; } .highlight{ box-shadow: 0px 2px white, 0px 10px orange; text-decoration: underline solid red 2px; text-underline-offset: 2px; }
<span class="paragraph">I'd far rather be <span class="highlight">happy than right</span> any day</span>
Using outline
and clip-path
使用
outline
和clip-path
span { text-decoration: underline; /* first underline */ outline: 5px solid orange; /* second underline */ outline-offset: 2px; /* control the gap */ clip-path: inset(0 0 -100vmax); } p { font-size: 30px; font-family: sans-serif; line-height: 1.4; }
<p> <span>Happy than right</span> is to set underline color. </p>
Also with gradient to support multi-line of text:还带有渐变以支持多行文本:
span { text-decoration: underline; background: linear-gradient(0deg,orange 5px,#0000 0); padding-bottom: 7px; /* control the gap */ } p { font-size: 30px; font-family: sans-serif; line-height: 1.4; }
<p> <span>Happy than right is to set underline color with multiline of text</span> </p>
You may try to apply different span with different style您可以尝试应用不同风格的不同跨度
.doubleHightlight{
box-shadow:
0px 2px yellow,
0px 10px orange;
}
.singleHightlight{
box-shadow:
0px 2px yellow,
}
You can surround text with a span and give it a border, like so:你可以用 span 包围文本并给它一个边框,如下所示:
<span>happy than right<span>
span {
text-decoration: underline;
text-decoration-color: red;
border-bottom: 1px solid orange;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.