Responsive Web Design

Responsive Web Design: Apply Different Media Queries for Different Resolutions

Spread the love

Responsive Web Design: To implement different media queries for different resolutions we have to use a media query which is mentioned below you have to use a media query to make the website responsive as per the screen design so that the website is able to work according to the Computer, Tablet, and Mobile Screens.

Example:-

Create index.php File and add style.css link also.

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Responsive Web Design</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body> 
<h1>Responsive Web Design : Apply Different CSS for different resolutions</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</body>
</html>

This is the style.css File:

*{
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
@media screen and (min-width: 320px) {
  body {
    background-color: red;
  }
}

@media screen and (min-width: 760px) {
  body {
    background-color: yellow;
  }
}

@media screen and (min-width: 1200px) {
  body {
    background-color: blue;
  }
}
}
 

Output:-

Computer Screen View

In the Computer screen view, we use this media screen (min-width 1200).

Teblet Screen View

In the Tablet screen view, we use this media screen (min-width 760).

Mobile Screen View

In the Mobile screen view, we use this media screen (min-width 320).


Spread the love

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *