Background Gradient 100% body CSS

I need a body background that used the whole viewport. Time ago I used to see solutions like html{ height: 100%;} or set in the body.

None of these worked for me in my different scenarios when using a background gradient.

Solution: fixed

Adding fixed at the background gradient style fixes everything everywhere. Weather the page is short (smaller than the browser window), long pages, iPad, iPhone...

Here's a background gradient example with the fixed attribute.

View Demo

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.