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

210
Views
Image div overlay and preserving position during resize

I am placing a div on top of an responsive image, like this: enter image description here

When I resize, I lose the position of the div tag, like this: enter image description here

How can I resize this overlay div so that its size is proportionally resized and its position is maintained, when the screen size changes?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Wrap the image in a container with percentage width and create a square using percentage and padding value. After that align the square using position: absolute and percentage value.

.container {
  position: relative;
}

.lotus-image {
  width: 100%;
}

.box {
  position: absolute;
  top: 30%;
  right: 20%;
  width: 30%;
  padding-bottom: 30%;
  border: 4px solid red;
  color: white;
}

.box-content {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
}
<div class="container">
  <img src = "https://img.freepik.com/free-photo/blossoming-pink-lily-flowers-swamp-natural-background_548832-3024.jpg?size=626&ext=jpg" class="lotus-image" />
  <div class="box">
    <div class="box-content">
      <span>Hello</span>
    </div>
  </div>
</div>

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