Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Underline, strikethrough and overline (with styles and colors) in one element

Tags:

html

css

I want to get only one <span> with three lines (underline, strikethrough and overline) like this: (That is only example, I want to change it dynamically)

but I can't use few text-decorations in one element like this:

span {
    text-decoration: overline dotted green;
    text-decoration: line-through wavy aqua;
    text-decoration: underline double red;
}

How can I do this using one <span>? Maybe I can use ::after and ::before or another languages like SASS or LESS?
Thanks for help.

like image 231
Kacper G. Avatar asked Aug 29 '17 06:08

Kacper G.


People also ask

Which CSS property can be used to make text with an underline and overline or line-through?

The text-decoration property adds an underline, overline, line-through, or a combination of lines to selected text.

Which CSS property has values such as overline line-through underline?

The CSS text-decoration property defines the text formatting of an element such as underline, overline, line-through and blink.

How do you underline a style in CSS?

The property text-decoration-line is used to underline the text. This property has three values that are overline, underline, or line-through. So, the value underline is used to underline the text in CSS. This value draws the underline beneath the inline text.


3 Answers

Use display:inline-block and border-top and border-bottom and text-decoration

span{
  display:inline-block;
  border-top:dotted 1px #000;
  border-bottom:thick double red;
  text-decoration: line-through wavy aqua;
}
<span>Some Text</span>

For the first comment

span{
  display:inline;
  text-decoration: line-through wavy aqua;
  font-size:22px;
  position: relative;
}
span:after {
  position: absolute;
  content: "Some Text";
  left: 0;
  top: 0;
  text-decoration: underline wavy red;
  z-index:-1;
  color:white;
}
	
span:before {
  position: absolute;
  content: "Some Text";
  left: 0;
  top: 0;
  text-decoration: overline wavy black;
  z-index:-1;
  color:white;
}
<span>Some Text</span>

For the last comment

span{
  display:inline;
  text-decoration: line-through wavy aqua;
  font-size:22px;
  position: relative;
}
span:after {
  position: absolute;
  content: "S";
  left: 0;
  top: -100%;
  text-decoration: underline wavy black;
  z-index:-1;
  color:white;
  width: 100%;
  letter-spacing: 1000px;
  overflow: hidden;
}
	
span:before {
  position: absolute;
  content: "S";
  left: 0;
  top: 0;
  text-decoration: underline wavy red;
  z-index:-1;
  color:white;
  width: 100%;
  letter-spacing: 1000px;
  overflow: hidden;
}
<span>Some Text</span>
like image 154
Jishnu V S Avatar answered Oct 12 '22 22:10

Jishnu V S


span1 {
    text-decoration: line-through overline underline dotted green;;
}
span2 {
    text-decoration: line-through overline underline wavy aqua;
}
span3 {
    text-decoration: line-through overline underline double red;
}
<span1>Some text</span1>
<span2>Some text</span2>
<span3>Some text</span3>
like image 37
Aashish Avatar answered Oct 13 '22 00:10

Aashish


Try using display block, and borders

span{
  display:inline;
  border-top:dotted 5px #000;
  border-bottom:thick double #ff0000;
  text-decoration: line-through wavy aqua;
  font-size:5rem;
  width: auto;
}
<span>Some Text</span>
like image 44
bdalina Avatar answered Oct 13 '22 00:10

bdalina