:has()当我在caniuse.com上检查CSS 选择器时,它告诉我自 Firefox103 以来,它已经
在 Firefox 中,layout.css.has-selector.enabled 标志后面支持。
那么如何找到这个标志并启用它呢?
我想做一些类似于justify-content:space-aroundor的事情justify-content:space-between,但使用:
通过换行元素会很简单,但我不能,因为这些项目(.left、.middle、.right)将是影响下面元素样式的复选框(并且没有良好支持的父选择器)。
我找到了这个答案来模拟first-of-class右侧,但没有找到类似于 emulate 的东西last-of-class。
/* emulate first-of-class */
.container>.right {
margin-left: auto;
}
.container>.right~.right {
margin-left: unset;
}
Run Code Online (Sandbox Code Playgroud)
这是我当前尝试的一个片段:
/* emulate first-of-class */
.container>.right {
margin-left: auto;
}
.container>.right~.right {
margin-left: unset;
}
Run Code Online (Sandbox Code Playgroud)
.container {
display: flex;
flex-wrap: wrap;
}
input {
display: none;
}
label {
padding: 0 10px;
background-color: orange;
}
.container>.right {
margin-left: auto; …Run Code Online (Sandbox Code Playgroud)