html - 这些CSS行之间有什么区别

标签 html css css-selectors

#cssmenu ul li.hover,
#cssmenu ul li:hover {position: relative; z-index: 599; cursor: default;}
#cssmenu ul ul {visibility: hidden; position: absolute; top: 100%; left: 0; z-index: 598; width: 100%;}
#cssmenu ul ul li {float: none;}

1) "li.hover"和 "li:hover"有什么区别?

2) “ul ul li”到底是什么意思?为什么有 2 个“ul”元素?

最佳答案

li.hoverli 元素为目标,该元素也具有 hover 类,例如:

<li class="hover"></li>

li:hover 以任何 li 元素的悬停状态为目标。

ul ul liul 元素中的任何 li 元素为目标,而 ul 元素又位于 another ul 元素,像这样:

<ul>
  <li>
    <ul>
      <li>This is the element that would be targeted</li>
    </ul>
  </li>
</ul>

关于html - 这些CSS行之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34713493/

相关文章:

javascript - 固定页眉/页脚将垂直滚动条保持在顶部?

css - 实现中间带有文本的分隔线

html - 在另一个中心 div

java - 从 Selenium 中获取 UL 标签的所有值

jQuery 动画不够流畅

html - Bootstrap 导航栏响应 Logo

javascript - 根据窗口高度 Bootstrap 模态高度

jquery - 如何使用 img 标签在不拉伸(stretch)移动设备的情况下全屏显示 Bootstrap slider 图像?

javascript - 文档 querySelectorAll 查找元素属性名称的一部分?

jQuery 引用 (this) 不起作用?