HTML CSS examples for CSS Layout:Responsive Media
Using media query to change background
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> #image {<!-- w ww. j av a2s . c om--> background:url('https://www.java2s.com/style/demo/Google-Chrome.png'); background-color:Chartreuse; } @media screen and (min-width:300px) { #image { background:url('https://www.java2s.com/style/demo/Google-Chrome.png'); background-color:yellow; } } </style> </head> <body> <div id="image"> </div> <div id="image"> </div> <div id="image" style="width:20px;height:20px"> </div> </body> </html>