有没有隐藏元素内容的方法,但保持其:before
内容可见? 说我有下面的代码:隐藏元素,但显示CSS生成的内容
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
,但随后额外空间似乎使用彩色 - 被添加:透明;但是然后,当然,跨度的内容仍然占据空间
- 使用
text-indent: -....px
,但-
(?)
- 这是通过搜索引擎皱眉和
- 似乎不是为span元素工作(?)
任何其他的想法我该如何做到这一点?
我个人会建议使用CSS在JavaScript中,因为一些用户可能有** **停用。 – anroesti 2011-02-06 10:51:03
@andre_roesti对于已停用javascript的用户,1%,我认为是时候进一步深入 – Sotiris 2011-02-06 11:03:49
我认为,根据目标群体,不止1%已停用JavaScript,并且有[很好的理由](http ://programmers.stackexchange.com/questions/26179/why-do-people-disable-javascript)。 – anroesti 2011-02-06 11:06:43