有沒有隱藏元素內容的方法,但保持其: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