Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


Change content for screen size
by admin
 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; 
} 
}