I want to make a text with red wavy underline
and blue dashed overline
using text-decoration
.
This is my code: (working only in Mozilla Firefox) (don't works, because display only overline)
span {
font-size: 40px;
text-decoration: underline wavy red;
text-decoration: overline dashed blue;
}
<span> Some Text </span>
How can I do that effect using only
text-decoration
? (I know, it will work only in Mozilla Firefox)Thanks for help.
You can not have two values for one css property at the same time.
Workaround: wrap yout text in another span
and add separate text-decoration to each span:
span {
font-size: 40px;
}
.wavy {
text-decoration: underline wavy red;
}
.dashed {
text-decoration: overline dashed blue;
}
<span class="wavy">
<span class="dashed">Some Text </span>
</span>
Try This:
span {
position: relative;
text-decoration: underline wavy red;
border-top: 2px dashed blue;
}
<span> Some Text </span>
Aswer your comment is here:
span {
position: relative;
text-decoration: underline wavy red;
}
span:after {
position: absolute;
width: 100%;
height: 100%;
display: block;
content: '';
border-top: 2px solid blue;
top: 10px;
}
<span> Some Text </span>
A text will need to span over multiple lines, even a heading will do with narrow viewports found on smartphones.
Here's a multiline solution done with a linear gradient (well, 2 of them to reproduce the dashes):
Codepen in Scss (simply using 2 variables for font-size and line-height)
span {
font-size: 40px;
line-height: 1.5;
text-decoration: underline wavy red;
/*text-decoration: overline dashed blue;*/
background-image:
linear-gradient(to right, white 0, white 50%, transparent 50%, transparent 100%),
linear-gradient(to bottom, blue 0, blue 1px, transparent 1px, transparent 100%);
background-size:
8px 100%,
100% 60px;
background-position: left top, left top;
background-repeat: repeat, repeat;
}
<p><span> Some Text </span></p>
<p><span>Also<br>multiline</span></p>
Dashes can be freely modified (it's a gradient between transparent and white color, size them however you want)
来源:https://stackoverflow.com/questions/45791793/css-multiple-text-decorations-with-style-and-color