Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda