Cum ajustam dimensiunea divului la dimensiunea imaginei din background?

Simplu!

div{
    background-image: url('http://www.pets4homes.co.uk/images/articles/1111/large/feline-influenza-all-about-cat-flu-5239fffd61ddf.jpg');
    background-size: contain;
    background-repeat: no-repeat;
    width: 100%;
    height: 0;
    padding-top: 66.64%; /* (img-height / img-width * width) */
                /* (853 / 1280 * 100) */
}

Leave a Reply

Your email address will not be published. Required fields are marked *