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

98
Visualizações
change size of a image that's being fetched

So i made a website where i fetch an image from an api, i added a class to the div where the image is being inserted. I try to style the div in css and it doesn't change.

How can i modify the size of the image?

here's the code:

html:

<div class='roverImageStyles' id="roverImage"></div>

javascript


async function getimages() {
  const response = await fetch(`https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?earth_date=${document.getElementById("dateUserInput").value}&api_key=rwX3pO8mONvdxngtstqSuNfwhrwMoGTy6clxqSnu`)
  const data = await response.json()
  console.log(data)
  console.log(data.photos[counter].img_src) 
document.getElementById('roverImage').innerHTML = 

`<img src="${data.photos[counter].img_src}" /></a>`


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

0

You need to tell the image to fill the size of the container. Add the following to your CSS

.nasaImage {max-width:100%} 

and add the following to your JS

<img class="nasaImage" src="${data.photos[counter].img_src}" />
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