Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Use ":not" pseudoclass within SASS nesting

I am trying to convert some plain CSS to SCSS so I can take advantage of nesting. The code below is an example of where I want to define styles for a bunch of form field input types. In the plain CSS below, I'm setting the default, plus the :focus state of the fields. Except for one particular form field (a search field in my global header), where I'm using the :not negation pseudo-class selector.

input.text, 
input.title, 
input[type=email], 
input[type=password], 
input[type=tel], 
input[type=text], 
select, 
textarea {
    border: 2px solid #c3cbd6;
}

input.text:focus, 
input.title:focus, 
input[type=email]:focus, 
input[type=password]:focus, 
input[type=tel]:focus, 
input[type=text]:not(div.global-search > form > div > input.et_pb_s):focus, 
select:focus, 
textarea:focus {
    border: 2px solid #008ed4;
}

And here is my conversion to nested SCSS for the first block:

input.text, 
input.title, 
input[type=email], 
input[type=password], 
input[type=tel], 
input[type=text], 
select, 
textarea {
    border: 2px solid #c3cbd6;
    
    &:focus {
        border: 2px solid #008ed4;
    }
}

But the second CSS block is trickier to convert to SCSS, because I'm making an exception using the :not selector to exclude the search field from having a focus state like all the other forms.

How can I do this in SCSS?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Separate the SCSS for input[type=text], and write it with the :not selector

input.text, 
input.title, 
input[type=email], 
input[type=password], 
input[type=tel], 
select, 
textarea {
    border: 2px solid #c3cbd6;
    
    &:focus {
        border: 2px solid #008ed4;
    }
}

input[type=text] {
 &:not(div.global-search > form > div > input.et_pb_s) {
 &:focus {
        border: 2px solid #008ed4;
 }
}
}
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!