Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
How to make an image fit only 50% of the screen in NextJS

I'm trying to make a image fit only 50% of the screen in NextJS. NextJS provides an Image component that we have to use and not the image element. That Image component already has its own inline styling for the image element and wraps it in a styled span element. Currently I wrap that Image component in a span tag so I can style it but I'm finding it difficult to make it fit only 50% of the screen.

Code:

<div className='pagewrapper'>
  <section className='authpages_section'>
    <span className='authpages_heroimg'>
      <Image src='/assets/hero.png' alt='an hero img' />
    </span>
  </section>
  <section className='authpages_section'>
   <Logo />
   <div>{children}</div>
  </section>
</div>

styling:
.pagewrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;

  .authpages {
     &_section {
       flex-basis: 50%;
       height: 100vh;
     }

     &_heroimg {
       display: inline-flex;
     }
   }
}

Here's a visual representation:

visual representation

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Can you do it like this:

  1. For the .authpages_section set width: 50%
  2. For the Image element - add some class and set it styles to max-width: 100%

Update To achive what you need to do it remove the layout="fill" property, so your component will actually look like:

 <Image
   src={HeroImg}
   alt="an hero img"
 />
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda