Newbie here. I am curious how to target with CSS code a specific mobile phone with maximum screen width of like maybe 768px – meaning I want the CSS code to take effect only if the screen is 768 or below. I hope that make sense. Thank you in advance.
You can make use of @media rule of CSS like below.
/* Set the background color of body to tan */
body {
background-color: tan;
}
/* On screens that are 992px or less, set the background color to blue */
@media screen and (max-width: 992px) {
body {
background-color: blue;
}
}
/* On screens that are 600px or less, set the background color to olive */
@media screen and (max-width: 600px) {
body {
background-color: olive;
}
}
For your case, you can use the following code directly.
@media only screen and (max-width: 768px) {
css code here…
}
Good luck!
Awesome you guys. I was able to make it work. Thanks for your help. Much appreciated.