I thought device-width
only worked on tablets and other mobile devices until today.
(Or maybe I was just wrong for a long time...)
.test {
width: 100px;
height: 100px;
padding: 5%;
}
@media only screen and (max-width : 1900px) {
.test {
background: blue;
color: yellow;
}
}
@media screen and (min-device-width : 768px) and (max-device-width : 1024px) {
.test {
background: #000000;
color: #ffffff;
}
}
<div class="test"> TEST</div>
If I set my monitor resolution as the width 1024x768, the media query below will work.
@media screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/*...*/
}
How can I target tablet and mobile with media queries since device-width
can work in desktop browsers?