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

238
Views
Absolute positioned element height exceeds parent on mobile

I have an element with a background image that contains an absolute positioned element at the bottom.

When the screen width gets narrower, the absolutely positioned element height gets increased and exceeds the parent element. As known that position absolute elements get out of the flow, so the parent height is not changed.

$(window).ready(function() {
  if ($(window).width() <= 767) {
    var heig = $('.overlay').height(),
      parent = $('.parent');
    parent.css('height', heig + 300 + 'px');
  }
});
html,
body {
  margin: 0;
  height: 100%;
}

* {
  box-sizing: border-box;
}

.parent {
  position: relative;
  min-height: 100vh;
  background-image: url(http://placehold.it/1000);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.overlay {
  background: #376c8d;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 30px 20px;
  border-radius: 160px 160px 0 0;
  font-size: 24px;
  opacity: 0.8;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="parent">
  <div class="overlay">
    <img src="http://placehold.it/100" />
    <p>Lorem ipsum dolor sit amet</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing eli</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <a href="/">Link</a>
    <p>Lorem ipsum dolor sit amet</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing eli</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <a href="/">Link</a>
  </div>
</div>

Is there is a way to keep the .overlay at the bottom, but all content is shown? Is there is a similar solution with CSS?

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

0

Constrain the proportion by making one property or another relative to the other.

background-size: 100% auto;

Edit:

Use responsive SVG as the .overlay to avoid layout reflow. Or output the content as an image if that suits your workflow or comfort level.

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!