如何在HTML中双击Strikeout文本?

Joh*_*Doe 17 html css tags

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

Dav*_*mas 16

我能想到的唯一(clean-ish)方法(不涉及添加其他元素)是使用:afterCSS伪元素:

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;
}
Run Code Online (Sandbox Code Playgroud)

JS小提琴演示.

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

更可靠的跨浏览器方法是在以下内容中使用嵌套元素(在本例中为a span)del:

<del>This text has a (contrived) double strike-through</del>
Run Code Online (Sandbox Code Playgroud)

加上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;
}
Run Code Online (Sandbox Code Playgroud)

JS小提琴演示.

  • 这是一个非常酷的技巧.但有一点需要注意,如果文本跨越多行,则不起作用. (2认同)

hev*_*ev1 9

您可以使用del带有text-decoration-style: double双删除线的标签。

<del style="text-decoration-style: double;">Text with double strike through <br/>
Multiline text also works.
</del>
Run Code Online (Sandbox Code Playgroud)

要在span标签或其他标签内的普通文本上应用双删除线,您可以使用text-decoration-line: line-throughtext-decoration-style: double

<span style="text-decoration-line: line-through; text-decoration-style: double;">
Text with double strikethrough
</span>
Run Code Online (Sandbox Code Playgroud)

这两个属性都可以与text-decoration速记结合使用。

<span style="text-decoration: line-through double;">
Text with double strikethrough
</span>
Run Code Online (Sandbox Code Playgroud)

另见:text-decoration-style, text-decoration-line,text-decoration


小智 6

css 没那么复杂:

.textDoubleStrikeThru {
    text-decoration: line-through;
    text-decoration-style: double;
}
Run Code Online (Sandbox Code Playgroud)

似乎这会在单个删除线所在的位置产生删除线,然后在其下方添加第二个删除线。


Bol*_*ock 0

文本中不能有超过一处印刷删除线。你最多可以有一个删除线和一个下划线,但我有一种感觉,这不是你想要的。然而,单独使用 HTML 或 CSS 的字体属性是不可能实现双删除线的。