Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda