CSS For Background Images
In trying to get an image to automatically cover the visible canvas without javascript, today I learned about:
background-size: cover;
replaces the need for a bunch of other hacks to get your background image to cover the canvas. Combine it with
height: 100%;
overflow: hidden;
width: 100%;
And you get a nice little element that's the size of the canvas. Position it absolutely and you're good to go.
Written by Winston Hearn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#