Skip to content

Instantly share code, notes, and snippets.

@RaminMammadzada
Created September 10, 2020 14:38
Show Gist options
  • Select an option

  • Save RaminMammadzada/2eadf832a617c2b1702e41f1906147b8 to your computer and use it in GitHub Desktop.

Select an option

Save RaminMammadzada/2eadf832a617c2b1702e41f1906147b8 to your computer and use it in GitHub Desktop.
Example usage of media queries in CSS
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-color: lightgreen;
}
@media only screen and (max-width: 400px) {
body {
background-color: yellow;
}
.color1{
color: white
}
}
@media only screen and (min-width:401px ) and (max-width: 600px) {
body {
background-color: white;
}
.color1{
color: red
}
}
@media only screen and (min-width: 601px) {
body {
background-color: black;
}
.color1{
color: purple
}
}
</style>
</head>
<body>
<p class="color1">Resize the browser window. When the width of this document is 600 pixels or less, the background-color is "lightblue", otherwise it is "lightgreen".</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment