css - 在 CSS 中,选择器“.class a”中的“a”是什么意思?
问题描述
我试图从 w3schools 中找出这个 CSS 示例:
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
text-align:center;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
显然,sidenav 是元素的类,人们可能会认为“a”是转换后 sidenav 的选择器......但我找不到带有示例的直接定义,所以我在这里向我的上级寻求澄清在我开始滥用这个之前。
简而言之,什么是“a”?
帮助和感谢!
解决方案
基本上a
将用于<a href=""></a>
html 中的标签,但这意味着您正在选择a
sidenav 中的标签。例子:
<!DOCTYPE html>
<html>
<head>
<style>
div a {
text-decoration: none;
}
</style>
</head>
<body>
<div>
<a href="#">I don't have an underline because I was selected in the div a</a>
</div>
<a href="#">I have an underline because I was not selected</a>
</body>
</html>
推荐阅读
- python-3.x - Django Aws Ses 电子邮件发送问题 b'Invalid MAIL FROM address provided'
- unity3d - 更新到 XR SDK 后的 Laggy Hololens App
- python-3.x - 如何计算一个或多个csv文件的每一行中指定字段中的字符串
- c++ - 我在 C++ 中练习数组以查找倒数时遇到了无限循环
- linux - 输入命令失败时如何使命令失败
- docker - docker-compose 与 springboot 和 redis
- android - 用 kotlin 编写的 Android Native 应用程序和 React Native 应用程序
- python - 在 Python 中使用之前显式声明变量,如 c++
- laravel - PhpOffice\PhpSpreadsheet\Reader\Exception 无法加载 .... 作为 DOM 文档
- swiftui - Vstack 冷却的 Hstack 元素分布不均