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

103
Views
Cómo configurar el componente siguiente/imagen al 100 % de altura

Tengo una aplicación Next.js y necesito una imagen que llene toda la altura de su contenedor y decida automáticamente su ancho en función de su relación de aspecto.

He probado lo siguiente:

 <Image src="/deco.svg" alt="" layout="fill" />

Este fragmento se compila correctamente, pero en la interfaz veo el siguiente error:

Error: la imagen con src "/deco.svg" debe usar las propiedades "ancho" y "alto" o la propiedad "sin tamaño".

Esto me confunde porque, según los documentos , estas propiedades no son necesarias cuando se usa layout="fill" .

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Esto es lo que funcionó para mí:

 <div style={{width: '100%', height: '100%', position: 'relative'}}> <Image alt='Mountains' src='/mountains.jpg' layout='fill' objectFit='contain' /> </div>
over 4 years ago · Santiago Trujillo Report

0

<img src="/path/to/image.jpg" alt="" title="" />

En SiguienteJS

 <Image src="/path/to/image.jpg" alt="" title="" width="100%" height="100%" layout="responsive" objectFit="contain"/>
over 4 years ago · Santiago Trujillo Report

0

Aquí hay una manera: por ejemplo, quiero tener una imagen que cubra todo el ancho y alto de su contenedor, que es un div.

 <div className={'image-container'}> <Image src={path} layout="fill" className={'image'} /> </div>

Y aquí está el estilo: (Hay un contenedor div que ocupa la mitad del ancho y la altura de la ventana gráfica y mi imagen lo cubrirá).

 // Nested Styling .image-container { width: 50vw; height: 50vh; position: relative; .image { width: 100%; height: 100%; position: relative !important; object-fit: cover; // Optional } } // Or Normal Styling .image-container { width: 50vw; height: 50vh; position: relative; } .image-container .image { width: 100%; height: 100%; position: relative !important; object-fit: cover; // Optional }
over 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!