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

130
Visualizações
Label for hidden date input not working on Chrome

I have a date input and I want it to have a placeholder, so I added a label and a display none. I have this code:

    document.querySelector("#date").onchange = (e) => {
      document.querySelector("#datelabel").innerHTML = e.target.value;
    }
    #datelabel {
        padding: 16px;
        border-radius: 15px;
        border: 2px solid rgba(0, 0, 0, 0.8);
        outline: none;
        font-size: 20px;
        transition: .2s;
        width: 200px;
        display: block;
    }
    <input type="date" name="date" id="date" style="display:none;">
    <label class="input" for="date" style="color:var(--text);" id="datelabel">Date</label>

It works fine on Firefox, but not on Chrome. If I remove the display of none of the input, it works, but I don't want the real input to be visible.

I tried to set a height and width to 0, an overflow: hidden, to remove the paddings and margins, but it created a mess in the display of my page, so I want to keep the display of none and find another solution.

Edit: I hid it another way:

position: absolute;
visibility: hidden;

It works now.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try this, it works

input {
    padding: 16px;
    border-radius: 15px;
    border: 2px solid rgba(0, 0, 0, 0.8);
    outline: none;
    font-size: 20px;
    transition: .2s;
    width: 200px;
    display: block;
}
::placeholder {
  color:black;
  font-size: 25px;
  
}
   <input type="text" name="date" id="date" id="datelabel" style="display:block;" placeholder="Date">

about 4 years ago · Juan Pablo Isaza 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