html - 如何在 HTML 中对文本进行双删除线?

标签 html css tags

我知道 <s> , <del><strike>标签。这些标签删除一次文本,但是我想不连续地删除文本 2 次。谁能告诉我该怎么做?提前致谢。

最佳答案

我能想到的唯一(干净的)方法(不涉及添加额外的元素)是使用 :after CSS 伪元素:

del {
    text-decoration: none;
    position: relative;
}
del:after {
    content: ' ';
    font-size: inherit;
    display: block;
    position: absolute;
    right: 0;
    left: 0;
    top: 40%;
    bottom: 40%;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
}

JS Fiddle demo .

这在 Internet Explorer < 9 中可能根本不起作用(但我没有任何 可以测试的 IE),但在最新版本中应该可以正常工作浏览器。 checkin :Ubuntu 11.04 上的 Firefox 4.x、Chromium 12 和 Opera 11。

一种更可靠的跨浏览器方法是在 del 中使用嵌套元素(在本例中为 span):

<del>This text has a (contrived) double strike-through</del>

加上CSS:

del {
    text-decoration: none;
    position: relative;
}
span {
    position: absolute;
    left: 0;
    right: 0;
    top: 45%;
    bottom: 35%;
    border-top: 1px solid #666;
    border-bottom: 1px solid #666;
}

JS Fiddle demo .

关于html - 如何在 HTML 中对文本进行双删除线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6395890/

相关文章:

javascript - 侧边栏与列重叠

javascript - 使用 Widget 代码中的 javascript 将光标图像左滑向右移动

javascript - 如何生成5个不同的随机数?

javascript - jquery淡出和淡入如何不闪烁

json - encoding/json unmarshal 缺少一个字段

javascript - 为什么使用 $route (AngularJS) 更改时带有此流程图的 div 无法正确调整大小

html - 复选框不可选择且尺寸较小

html - 如何修复 IE11 中的 Flexbox 粘性页脚

python - 父标签的子标签有特定属性值时,如何使用BeautifulSoup获取父标签名称值?

javascript - Javascript 新手,样式不会影响任何东西