简体   繁体   English

将ul上的CSS设置为悬停

[英]set css on ul li for hover

this is my html:- 这是我的html:-

<ul>
    <li>Activities</li>
    <ul>
        <li>Physical1</li>
        <ul>
            <li>Cricket</li>
            <ul>
                <li>One Day</li>
            </ul>
        </ul>
            <li>Test1</li>
            <ul>
                <li>Test At Abc</li>
            </ul>
                <li>Test2</li>
            <ul>
                <li>Test At Xyz</li>
            </ul>
    </ul>
</ul>

this is my csss:- 这是我的CSS:

ul > li > ul {
    display: none;

}

li:hover > ul {
    display: block;
    }

i want to hover on Activties then Display Physical1 and Test1 and Test2. 我想将鼠标悬停在“活动”上,然后显示Physical1和Test1和Test2。
i am try to above css but not success with them. 我试图超越CSS,但没有成功。
thanks. 谢谢。

To do a nested list you should put a <ul> element inside a <li> like that: 要执行嵌套列表,您应该将<ul>元素放在<li> ,如下所示:

<ul>
  <li>Blah blah
      <ul>
          <li>Nested blah blah</li>
      </ul>
   </li>
</ul>

Then your CSS rule: 然后,您的CSS规则:

li:hover > ul {
  display: block;
}

will work. 将工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM