我可以创建一个波浪下划线吗:
我只能得到一个实心边框:
.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>
没有背景图片:
.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>
带有背景图片:
.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>
下面是无需图像即可实现此目的的方法之一的示例。根据需要调整。
.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>
您可以使用 CSS
text-decoration-style
属性:
-webkit-text-decoration-style: wavy;
-moz-text-decoration-style: wavy;
text-decoration-style: wavy;
这适用于所有主要浏览器(IE 除外 - 如果您需要支持,那么您可能需要考虑使用图像)