Stretch and scale CSS background

Lawrence Dol picture Lawrence Dol · Dec 17, 2008 · Viewed 892.1k times · Source

Is there a way to get a background in CSS to stretch or scale to fill its container?

Answer

vinyll picture vinyll · Jan 26, 2012

Use the CSS 3 property background-size:

#my_container {
    background-size: 100% auto; /* width and height, can be %, px or whatever. */
}

This is available for modern browsers, since 2012.