Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda