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

135
Visualizações
How do I display some other image disabling another depending on screen resolution?

I wanted to display a different image for resolution 800px and a different one for resolution greater than 800px. How do I do that?

I am adding the code which I have written. (It's just for adding image on the page). This is the code for my main image means for all resolution.

<img src={alexagif} style={{ minWidth: "100%" }} />

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

What you're looking for is responsive images.

For example, from MDN:

<img srcset="elva-fairy-480w.jpg 480w,
         elva-fairy-800w.jpg 800w" 
 sizes="(max-width: 600px) 480px, 
        800px"
 src="elva-fairy-800w.jpg"
 alt="Elva dressed as a fairy">

In the example, the first line would be the smaller version of your image. The second is defining the larger image that should be rendered, and "sizes" is where you define the document width break-point for the images to switch. The final line is your original image/fallback source

Another way of handling this would be with swapping background-images using @media queries in your CSS/stylesheets.

about 4 years ago · Santiago Trujillo Relatório

0

You can use the <picture> tag as follows:

<picture>
  <!--source for screens larger than 800px-->
  <source media="(min-width:800px)" srcset="https://images.unsplash.com/photo-1659447055750-4a85ffdf119e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY2MDQ1NjI3NQ&ixlib=rb-1.2.1&q=80&w=1080">
  <!--source for default screens (smaller than 800px) -->
  <img src="https://images.unsplash.com/photo-1660337157394-7528d18332a9?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY2MDQ1NjIyMA&ixlib=rb-1.2.1&q=80&w=1080"> 
</picture>

about 4 years ago · Santiago Trujillo 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