When declaring a div and importing an image as background-image
, I need to declare the size ( height
and width
) of the div.
However, let's say I have an image size of 900x506 (example). And that I just declared div
and did not assign any size ( height
and width
) to it.
Home
Is it possible for me to import the image via css background-image: url('minhaimagem.jpg');
and my div automatically display it, even though I have not assigned any size ( height
and width
) to it?
(I do not know if it was very clear, another explanation ..)
How can I declare a div
, import an image as background
and my div
"get" the values of my image ( height
and width
)?
#imagem{
background-image: url('http://www.planwallpaper.com/static/images/techno_wallpaper_2_0_hd_by_gredius-d5o48do.jpg');
}
<div id="imagem">
</div>