【发布时间】:2011-06-22 05:11:49
【问题描述】:
有没有办法隐藏元素的内容,但保持其:before 内容可见?
假设我有以下代码:
HTML:
<span class="addbefore hidetext">You are here</span>
CSS:
.addbefore:before {
content: "Show this";
}
.hidetext {
// What do I do here to hide the content without hiding the :before content?
}
我试过了:
- 使用
display: none并在:before上设置display: inline,但两者仍处于隐藏状态 - 使用
width: 0; overflow: hidden;,但随后似乎添加了额外的空间(?) - 使用color: transparent;,但是当然span的内容还是占空间
- 使用
text-indent: -....px,但是- 这是不被搜索引擎和
- 它似乎不适用于 span 元素 (?)
关于我如何做到这一点的任何其他想法?
【问题讨论】:
标签: html css css-selectors