Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!