Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda