40
loading...
This website collects cookies to deliver better user experience
@media
declaration that gives to the applied block a condition. If the given condition is true then the corresponding rule is applied.types
:all /* apply to all media type devices */
print /* apply on printers */
screen /* apply on screens */
speech /* apply on speech synthesizers */
@media type
is optional and if we skip it, the all
type will be implied by default.@media
declaration based on different screen resolutions.@media screen and (min-width: 600px) {
/* Apply when the browser is at least 600px or above */
/* Equivalently we can write for any device */
/* @media (min-width: 600px) */
}
@media screen and (max-width: 800px) {
/* Apply when the browser is at maximum 800px or less */
/* Equivalently we can write for any device */
/* @media (max-width: 800px) */
}
@media screen and (min-width: 600px) and (max-width: 800px)
/* Apply when the browser is from 600px to 800px */
/* Equivalently we can write for any device */
/* @media (min-width: 600px) and (max-width: 800px) */
}
800px or less
, the navbar items
will be centered in a column and when the screen width size is 600px or less
, the navbar items
will be blue.@media (max-width: 800px) {
nav ul {
flex-direction: column;
text-align: center;
}
}
@media (max-width: 600px) {
nav ul {
flex-direction: column;
text-align: center;
}
nav {
background-color: rgb(62, 109, 149);
}
}
800px or less
, a button appears and the navbar becomes hidden. navbar items
will appear in a column and when the screen width size is 600px or less
, the navbar items
will be blue.@media (max-width: 800px) {
nav ul {
display: none;
flex-direction: column;
width: 100%;
}
nav ul.show {
display: flex;
}
.my-button {
display: block;
}
}
@media (max-width: 600px) {
nav ul {
display: none;
flex-direction: column;
width: 100%;
}
nav ul.show {
display: flex;
}
.my-button {
display: block;
}
nav {
background-color: rgb(62, 109, 149);
}
}