我通过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;
}
当我使用SASS 3.4.9编译它时,它会抱怨:
Error: Invalid CSS after "&::not(": expected pseudo_expr, was ":first-child)"
预期的CSS代码应如下所示:
.floating-label-form-group::not(:first-child){
padding-left:14px;border-left:1px solid #e1e1e1}
然而,似乎SASS不知道如何将&::not(
编译成CSS。有没有人有关于如何解决这个问题的想法?
答案 0 :(得分:18)
实际上,Sass是对的:那确实是无效的CSS。 :not()
是一个伪类,而不是伪元素,所以它应该只有一个冒号:
&:not(:first-child) {
padding-left: 14px;
border-left: 1px solid #e1e1e1;
}
答案 1 :(得分:-2)
放置引号:first-child,以下代码在Rais 4中为我工作
.floating-label-form-group::not(':first-child') {
padding-left: 14px;
border-left: 1px solid #eee;
}