Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't SASS compile pseudo_expr like `&::not(:first-child)`?

I got the following snippet by css2sass (Convert to 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;
  }

When I compile it using SASS 3.4.9, it complains:

Error: Invalid CSS after "&::not(": expected pseudo_expr, was ":first-child)"

The expected CSS code should look like this:

.floating-label-form-group::not(:first-child){
     padding-left:14px;border-left:1px solid #e1e1e1}

However, it seems that SASS doesn't know how to compile &::not( into CSS. Does anyone have ideas about how to fix this?

like image 428
Hanfei Sun Avatar asked Dec 25 '14 04:12

Hanfei Sun


Video Answer


1 Answers

Actually, Sass is right: that is indeed invalid CSS. :not() is a pseudo-class, not a pseudo-element, so it should only have one colon:

  &:not(:first-child) {
    padding-left: 14px;
    border-left: 1px solid #e1e1e1;
  }
like image 145
BoltClock Avatar answered Nov 15 '22 21:11

BoltClock