css media screen code example
Example 1: media queries les plus utilisees
/* Sur les écrans, quand la largeur de la fenêtre fait au maximum 1280px */
@media screen and (max-width: 1280px)
/* Sur tous types d'écran, quand la largeur de la fenêtre est comprise entre 1024px et 1280px */
@media all and (min-width: 1024px) and (max-width: 1280px)
/* Sur les téléviseurs */
@media tv
/* Sur tous types d'écrans orientés verticalement */
@media all and (orientation: portrait)
Example 2: orientation css max and min width media query
<style type="text/css">
@media only screen and (min-width: 960px) {
}
@media only screen and (min-width: 1440px) {
}
@media only screen and (min-width: 2000px) {
}
@media only screen and (max-device-width: 480px) {
}
@media only screen and (device-width: 768px) {
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
}
</style>
Example 3: css media screen
@media (max-width: 991px){
.mobile{
display: block;
}
}
Example 4: css @media
/* When the width is between 600px and 900px OR above 1100px */
@media screen and (min-width: 600px) and (max-width: 900px), (min-width: 1100px) {
div.example {...}
}
Example 5: media query
@media (max-height : 800px){ /* from 0 to 800 px max height applies */
p{
font-size:10px
}
}
Example 6: media css
@media only screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}