html - CSS - 一个元素中的下划线、删除线和上划线(带有样式和颜色)

标签 html css

我想得到只有一个 <span>像这样的三行(下划线、删除线和上划线):(这只是示例,我想动态更改它)

但我不能用几个 text-decorations在这样的一个元素中:

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

我如何使用一个 <span> 来做到这一点? ?也许我可以用 ::after::before或其他语言,如 SASS 或 LESS?
感谢您的帮助。

最佳答案

使用display:inline-blockborder-topborder-bottomtext-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>

对于第一条评论

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>

最后的评论

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>

关于html - CSS - 一个元素中的下划线、删除线和上划线(带有样式和颜色),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45932420/

相关文章:

html - 为什么 <p> 元素在两个几乎相同的 HTML 页面上的样式不同?

jquery - 隐藏表格第一行中的元素

css - 在任何屏幕分辨率上居中消息框

html - 屏幕缩放时,如何将 CSS 中的内联圆放在彼此的下面?

javascript - AngularJS:ngAnimate 在 IE10 上随机失败

html - 在没有 html 的情况下使用 css sprites

java - 为什么在 HTML 中显示转义字符?

html - 添加自定义顶点 :inputFile icon/image

html - 手机导航背景色

html - CSS 下拉菜单在 IE 中消失