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

233
Vistas
how can I change the css of a selected <Option/> of <Select/>?

I am using React.js, and ant-design components.

I have a <Select/> component with a few <Option/> inside of it, now I know that on each selected option has this automatic hue added to it, but I want to change it do a different one, and also to change the background etc, but only if an option has been selected.

is there a way to do that?

(Select, Option Components - https://ant.design/components/select/ )

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

<select>
  <option selected="">1</option>
  <option>2</option>
</select>
<style>
  option[selected]{
    background: #f00;
  }
</style>

This is the right CSS for this but I think it doesn't work on every browser. Even on Firefox it works only if you hover over the expanded options. Changing CSS styles of inputs was always pretty bad and weird. That's why there are libraries for that.

about 4 years ago · Santiago Trujillo Denunciar

0

first of all sorry for my bad english, i dont know it is the best answer but when i want to change an element style i use its class and give that class a css. for selectbox you can use ant-select-selector in your css file :

.ant-select-selector{background-color:green}

if you want to check class for diffrent things you can check the element in dev tools.If you look at this img when i select to selectbox div i can see its own class and i can change its background-color.

about 4 years ago · Santiago Trujillo 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