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

254
Views
¿Cómo crear este diseño de "imagen-superposición-div" mientras se mantiene receptivo con CSS y/o JS? (Ver ejemplo de imagen)

¿Cómo colocaría la imagen (rectángulo oscuro) para superponer el div de ancho completo de color sólido de fondo exactamente como se muestra en la imagen (en un punto de alrededor del 60 % de altura), mientras se mantiene igual en diferentes tamaños de pantalla (sensible)? diseño de escritorio y móvil con imagen

Intenté colocar el color de fondo div como primer elemento HTML y aplicar este CSS:

 .full-width-hero-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: gray; }

Mientras que el resto del contenido está en flujo normal en un contenedor flexible. Esto funcionó para mi pantalla, pero al cambiar el tamaño de la ventana, también cambia el tamaño del fondo. Por lo tanto, en pantallas grandes, el fondo tiene una altura mayor que la imagen superior, lo que hace que la imagen aparezca dentro de ella.

Supongo que podría usar consultas de medios CSS y ajustar el tamaño del fondo manualmente, pero me pregunto si hay una mejor manera.

Agradecería cualquier idea.

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

0

esto puede ayudar, usando "margin-top" configuro el contenido en la imagen.

 body { margin: 0; font-family: sans-serif; } .main-hero { height: 100%; display: table; width: 100%; padding-bottom: 100px; } .main-hero .image-wrapper img { width: 100%; height: auto; object-fit: cover; max-height: 800px; } .main-hero .content { max-width: 800px; margin: -150px auto 0 auto; display: table; width: 100%; text-align: center; background-color: #fff; box-shadow: 0px 5px 10px 0px #0000008a; padding: 50px; position: relative; } .main-hero .content p { font-size: 20px; } /*//for tablet*/ @media only screen and (max-width: 991px) { .main-hero .content { max-width: 600px; } } /*//for mobile*/ @media only screen and (max-width: 600px) { .main-hero .content { max-width: 210px; padding: 25px; margin: -80px auto 0 auto; } .main-hero .content p { font-size: 12px; } }
 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <link rel="stylesheet" href=""> </head> <body> <div class="main-hero"> <div class="image-wrapper"> <img src="https://images.unsplash.com/photo-1643303808869-ecfbf62fe81e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1074&q=80"> </div> <div class="content"> <h2>Main Title</h2> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> </body> </html>

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!