1

In the following code I would like to hide "Hello world" but keep visible my ul.myphotos with CSS.

Here is a sample of what I have:

<ul class="content">
    <li>
        Hello world
        <ul class="myphotos">
            <li>Photo1</li>
            <li>Photo2</li>
        </ul>
    </li>
</ul>
4

2 回答 2

2

你不能用你有 atm 的代码来做到这一点(嗯,是的,你可以用一些相当“hacky”的技巧......)。

我会提出一个干净的解决方案:将该文本包装在一个单独的标签中,例如:

<ul class="content">
    <li>
        <span>Hello world</span>
        <ul class="myphotos">
            <li>Photo1</li>
            <li>Photo2</li>
        </ul>
    </li>
</ul>

现在您可以轻松地说:

li > span{
   display:none;
}
于 2012-07-02T16:29:06.567 回答
1

Put Hello World in <span> tags with an id and then hide that.

于 2012-07-02T16:29:40.980 回答