Han*_*Sun 8 css sass css-selectors
我通过css2sass获得了以下片段(转换为SCSS)
.floating-label-form-group {
position: relative;
margin-bottom: 0;
padding-bottom: .5em;
border-bottom: 1px solid #e1e1e1;
input, textarea {
z-index: 1;
position: relative;
padding-right: 0;
padding-left: 0;
border: 0;
border-radius: 0;
font-size: 1.5em;
background: 0 0;
box-shadow: none!important;
resize: none;
}
label {
display: block;
z-index: 0;
position: relative;
top: 2em;
margin: 0;
font-size: .85em;
line-height: 1.764705882em;
vertical-align: middle;
vertical-align: baseline;
opacity: 0;
-webkit-transition: top .5s ease,opacity .5s ease;
-moz-transition: top .5s ease,opacity .5s ease;
-ms-transition: top .5s ease,opacity .5s ease;
transition: top .5s ease,opacity .5s ease;
}
&::not(:first-child) {
padding-left: 14px;
border-left: 1px solid #e1e1e1;
}
Run Code Online (Sandbox Code Playgroud)
当我使用SASS 3.4.9编译它时,它会抱怨:
Error: Invalid CSS after "&::not(": expected pseudo_expr, was ":first-child)"
Run Code Online (Sandbox Code Playgroud)
预期的CSS代码应如下所示:
.floating-label-form-group::not(:first-child){
padding-left:14px;border-left:1px solid #e1e1e1}
Run Code Online (Sandbox Code Playgroud)
但是,似乎SASS不知道如何编译&::not(成CSS.有没有人有关于如何解决这个问题的想法?
Bol*_*ock 20
实际上,Sass是对的:那确实是无效的CSS.:not()是一个伪类,而不是伪元素,所以它应该只有一个冒号:
&:not(:first-child) {
padding-left: 14px;
border-left: 1px solid #e1e1e1;
}
Run Code Online (Sandbox Code Playgroud)