HTML5 新手 Q |导航 > UL VS 导航 UL / 有什么区别?



我只是想知道,在 CSS3 中,当我们键入示例时:

nav > ul{
margin: 0px;
}

这意味着 ul 在 nav 元素内的边距将为 0px。好。

但!什么意思?与导航> ul 有什么区别?!:

nav ul{
margin: 0px;
}

另外,要完成的小问题:导航的目的是什么?我们可以在没有它的情况下制作导航菜单。

谢谢

技术。

ul 是 nav 的子项,对于案例 "nav> ul",而 ul 是 nav 的后代,对于案例 "nav ul"。

例如:

<div class="first">
<p></p>
<p></p>
<p></p>
<p></p>
<div class="second">
<p></p>
</div> 
</div>
.first p {
/*** This will target all the <p> elements in the HTML above ***/
}
.first > p {
/*** This will target all <p> elements except the one nested within the "second" class ***/
}

来源: https://teamtreehouse.com/community/difference-between-descendant-and-child-selectors

最新更新