How to Double Strikeout a Text in HTML?(如何在 HTML 中双删除线?)
问题描述
我知道 <s>
、<del>
和 <strike>
标签.这些标签删除一个文本一次,但是我想不连续地删除一个文本 2 次.谁能告诉我该怎么做?提前致谢.
I know about <s>
, <del>
and <strike>
tags. These tags strike out a text once, however I want to strike out a text 2 times discontinuously. Can anyone please tell me how to do it? Thanks in advance.
推荐答案
我能想到的唯一(干净的)方法(不涉及添加其他元素)是使用 :after
CSS 伪元素:
The only (clean-ish) way I could think of (that doesn't involve additional elements being added) is to use the :after
CSS pseudo-element:
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 演示.
这很可能在 Internet Explorer 中根本不起作用 <9(但我没有 any IE 可以用来测试),但应该可以在最新的浏览器中使用.已签入:Ubuntu 11.04 上的 Firefox 4.x、Chromium 12 和 Opera 11.
This is likely to to not work at all in Internet Explorer < 9 (but I don't have any IE with which I could test), but should be functional in up-to-date browsers. Checked in: Firefox 4.x, Chromium 12 and Opera 11 on Ubuntu 11.04.
更可靠的跨浏览器方法是在 del
中使用嵌套元素(在本例中为 span
):
A more reliable cross-browser method is to use a nested element (in this instance a span
) within the del
:
<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 演示.
这篇关于如何在 HTML 中双删除线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 HTML 中双删除线?


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01