Pick up the size of an image

1

Is it possible to get the javascript size of an image outside of my directory?

For example in this usage:

.divExterna{
background-image:url(http://www.backsite.com.br/datafiles/suite/escritorio/aplicativo/conteudo/album_fotografico/769.jpg),
height: seu_tamanho
}

I'd like to get your size to apply as the height of my div.

    
asked by anonymous 29.07.2016 / 17:03

1 answer

1

So (as it has structured css) will not give because the image is in the background, it can however do so:

div {
 display: inline-block;
 border: 2px solid yellow; /* isto é só para ver a div (altura/comprimento) */
 height: 150px;
}
img {
   height: 100%; 
}
<div>
  <img src="https://catracalivre.com.br/wp-content/uploads/2015/10/imagens-3D_11.gif">
</div>

In this way the image will always have the height (height) defined in the parent element (div in this case)

    
29.07.2016 / 17:10