html - HTML5新手Q | nav > ul VS nav ul / 有什么区别?
问题描述
我只是想知道,在 CSS3 中,当我们输入示例时:
nav > ul{
margin: 0px;
}
这意味着 nav 元素内的 ul 边距将为 0px。好的。
但!这是什么意思 ?nav > ul 有什么区别?!:
nav ul{
margin: 0px;
}
另外,小问题要完成: nav 的目的是什么?我们可以在没有它的情况下制作导航菜单。
谢谢,
技术。
解决方案
对于“nav > ul”的情况,ul 是 nav 的子代,而对于“nav ul”的情况,ul 是 nav 的后代。
例如:
<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
推荐阅读
- laravel - Laravel通过将列名作为字符串传递给数据库结果来获取特定的列名值
- c# - 将 Blazor 从 3.1 升级到 5.0 时出错“没有与名称‘PreferExactMatches’匹配的属性”
- database - 将数据库数据拆分为多个表而不是将所有内容存储在 PostgreSQL 的一个表中是否是个好主意?
- python - PyCharm venv 失败:'没有这样的选项:--build-dir'
- python - python中的TPOT错误无法使用具有不同长度的切片索引器进行设置
- pip - 使用 pip 降级或安装早期版本的软件包
- c++ - 为什么即使我放了一个 break 语句,我的程序也会一直循环
- javascript - 设备显示未定义
- laravel - 如何在 laravel Eloquent 中忽略大小写和空格
- r - 功能...故障(malcoder!),包括group_by和export