Change content for screen size
at 2019-03-06 04:30:00.
we have a html page but it because it’s hard to use on a small screen. So in this example we will change a font size and make content of a div change. For example if you use ads and need to have a compliantly different code for size change.
We will have a .html and a .css file
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href='main.css' /> <meta charset="utf-8"> <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" /> </script> </head> <body> <div id="primaryContainer" class="primaryContainer clearfix"> <div id="ad1"> ad number 1 </div> <div id="ad2"> ad number 2 </div> <div id='box2' class='clearfix'> <h1>big text for larger screen becomes small text for smaller screen</h2> </div> </div> </body> </html>
#ad2 { display:none; } @media only screen and (max-width: 480px) { h1 { font-size: 18px; } #ad1 { display:none; } #ad2 { display:inline; } }