beta.blog

CSS: Stretch background to page size

by on Jan.29, 2023, under News

The following is a quick example on how to stretch a background image to the actual page size in pure CSS.

Unlike stretching the width/height 100% each, this method will scale fine, also on mobile devices:

background: url(images/bg.jpg) no-repeat center center fixed;
background-size: cover;

Works great on all modern browsers.

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!