Home
CSS
RWD Images
Tryit: Change background image depending on device width
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> /* For device width smaller than 400px: */ body { background-repeat: no-repeat; background-image: url('img_smallflower.jpg'); } /* For device width 400px and larger: */ @media only screen and (min-device-width: 400px) { body { background-image: url('img_flowers.jpg'); } } </style> </head> <body> </body> </html>