<分区>
标签 css sass css-selectors
<分区>
我正在尝试选择所有元素,然后选择具有 btn
类的元素,具有 navbar
、footer
或 mobile-menu
类。
我有这个代码:
*:not(.navbar):not(.footer):not(.mobile-menu) {
.btn {
font-size: 20px;
padding: .8rem 2rem;
}
}
但它不起作用。
谁能给我解释一下原因吗?
编辑:我正在使用 sass
最佳答案
给定:
<body>
<div class="navbar">
<div class="btn">
</div>
</div>
</body>
*:not(.navbar):not(.footer):not(.mobile-menu)
火柴<body>
然后 .btn
火柴<div class="btn">
.
没关系 *:not(.navbar):not(.footer):not(.mobile-menu)
不匹配 <div class="navbar">
因为<div class="btn">
仍然是 <body>
的后代.
关于css - 为什么是:not() selector not working with the * selector?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55952721/
相关文章:
css - :nth-child() and :nth-of-type() selectors的实际使用
twitter-bootstrap - 我在 Bootstrap 媒体查询中遇到错误,请通过正确的代码指导我
jquery - 如何为 div 制作固定的 webkit-mask?
javascript - 在哪里可以找到或覆盖 _navbar.scss?
css - Webdriver.io 如何根据页面上类似元素的数量选择和更改元素
html - 使用 CSS 选择器选择 HTML 中的特定元素
javascript - 失去 HTML 表中文本字段的焦点以启动 JQuery 计算