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

117
Visualizações
h3 not displaying in absolutely positioned div

Im having difficulty displaying my h3 on the page. I have an absolutely positioned div that is going to move around my window. Inside I have an image and an h3 that moves when the div is moves. The image is displaying on the screen but the h3 is not. The height of the h3 is 0, I've tried using the clearfix trick, setting width/height and overflow: auto, but to no avail.

.asteroid {
        position: absolute;
}
.asteroid-name {
    color: white;
    font-size: 2rem;
}
<div class="asteroid">
    <h3 class="asteroid-name" style="display: block">
    <img .... width, height and a rotation specified here>
</div>

The reason I specify display block for the h3 is because I am adding all these elements through my JS. Each one of these divs is generated based on an object I receive from an API. I initially have 2 h3s, both set to "display: none" and based on the direction of travel, I choose to either display the h3 above this img, or an h3 that would be below it

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Correct me if I'm wrong but the h3 element you have specified in your example contains no content and has no closing tag, so I don't understand what you're expecting to see?

See below code example where I've added content and the closing tag.

.asteroid {
  position: absolute;
  background-color: blue;
}

.asteroid-name {
    color: white;
    font-size: 2rem;
}
<div class="asteroid">
  <h3 class="asteroid-name" style="display: block">Test</h3>
  <img src = "https://via.placeholder.com/150">
</div>

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