Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A wavy underline in CSS [duplicate]

Can I create a wavy underline as this : http://i.imgur.com/aiBjQry.png
I can only get a solid border :

.err {
  border-bottom:1px solid red;
  display: inline-block;
}
<div>A boy whose name was Peter was <div class="err">woking</div> down the street</div>
like image 628
Amelie P Avatar asked Jan 26 '15 14:01

Amelie P


People also ask

What is wavy text-decoration?

Definition and UsageThe text-decoration-style property sets the style of the text decoration (like solid, wavy, dotted, dashed, double). Tip: Also look at the text-decoration property, which is a short-hand property for text-decoration-line, text-decoration-style, text-decoration-color, and text-decoration-thickness.

How do I Unline an underline in CSS?

By setting the text-decoration to none to remove the underline from anchor tag. Syntax: text-decoration: none; Example 1: This example sets the text-decoration property to none.

How do I 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

Without background image:

.err {
  display: inline-block;
  position: relative;
}
.err:before {
  content: "~~~~~~~~~~~~";
  font-size: 0.6em;
  font-weight: 700;
  font-family: Times New Roman, Serif;
  color: red;
  width: 100%;
  position: absolute;
  top: 12px;
  left: -1px;
  overflow: hidden;
}
<div>A boy whose name was Peter was
  <div class="err">woking</div> down the street</div>

With Background image :

.err {
    display: inline-block;
    position:relative;
    background: url(http://i.imgur.com/HlfA2is.gif) bottom repeat-x;
}
<div>A boy whose name was Peter was <div class="err">woking</div> down the street</div>
like image 159
The Pragmatick Avatar answered Oct 16 '22 17:10

The Pragmatick


Below is an example of one of the ways that you can achieve that without an image. Adjust as needed.

.err {
  border-bottom:2px dotted red;
  display: inline-block;
  position: relative;

}

.err:after {
  content: '';
  width: 100%;
  border-bottom:2px dotted red;
  position: absolute;
  font-size: 16px;
  top: 15px; /* Must be font-size minus one (16px - 1px) */
  left: -2px;
  display: block;
  height: 4px;

  
  }
<div>A boy whose name was Peter was <div class="err">woking</div> down the street</div>
like image 32
Sleek Geek Avatar answered Oct 16 '22 18:10

Sleek Geek


You could use the CSS text-decoration-style property.

-webkit-text-decoration-style: wavy;
-moz-text-decoration-style: wavy;
text-decoration-style: wavy;

However, this is limited to Firefox and Safari. You may need to consider using a image instead.

like image 16
Richard Blyth Avatar answered Oct 16 '22 18:10

Richard Blyth