在元素中隐藏文本节点,但不隐藏子节点

问题描述:

我有点麻烦的CSS,似乎找不到一个解决方案。我有这个HTML

I'm having a little trouble with CSS and can't seem to find a solution. I have this HTML

<div id="closelink">
  <a href="">Close</a>
  Click to close
</div>

现在我想隐藏文本«点击关闭»,而不隐藏div,

Now I want to hide the text «Click to close» only, without hiding neither the div, nor the link within it.

可以这样做吗?

visibility 属性可以覆盖children元素,因此您可以这样做:

The visibility attribute can be overriden on children elements, so you are able to do this:

<div id="closelink">
  <a href="">Close</a>
  Click to close
</div>

CSS:

#closelink {
    visibility:collapse;
}

#closelink a{
    visibility:visible;
}

结果是: http://jsfiddle.net/pavloschris/Vva84/