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

732
Visualizações
datalist option width smaller than input width when px more than 600px. How do I fix it dynamically on chrome

Hi all I'm using flask WTForm form control class for the width, but not sure how to do that in snipet so i hardcode the width.

The issue I'm facing is that the input is really long, but the dropdown option don't match the input width. When you run the snippet you could see that the dropdown is like 1/10 of the input width. I tried giving option and the datalist the same width, but nothing works.

How would I make it so the option dropdown on chrome the same width as my input thanks

<input class="form-control" type="text" id="color" style = "width:800px" list="colors_data">
                        <datalist id="colors_data"class="form-control"style = "width:800px">
                          <option style = "width:800px"value="red"></option>
                          <option style = "width:800px"value="orange"></option>
                          <option style = "width:800px"value="green"></option>
                          <option style = "width:800px"value="blue">The color of the sky</option>
                        </datalist>

Edit: change size to 800px I try creating my own datalist via this link but I'm facing the same issue Creating a HTML5 datalist on the fly

I included a picture to show the problem more clearly. As you can see the dropdown option is a lot smaller than the input itself. How do I fix this thanks enter image description here

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Ok now that I finally know what you wanted, here is your code:

<input style = "width:200px; height:30px;" list="colors_data">
<datalist id="colors_data">
<option value="red">The color of apple</option>
<option value="orange">The color of sun</option>
<option value="green">The color of grass</option>
<option value="blue">The color of the sky</option>
</datalist>

over 4 years ago · Santiago Trujillo Relatório

0

The <datalist> element is very inflexible - you cannot style it at all as its styling comes from the browser and the browser only.

If you want to set a width or apply any other styling, you're going to have to settle with a custom <datalist>.

You could, however, try programmatically adding &nbsp; to the value to artificially widen the length of the <datalist>, but Chrome sets a maximum width on datalists, so beyond a certain point it will simple cut off.

over 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