Reputation: 1409
How do i apply styles for differnt screen resolutions
For example: I have a computer with max screen resolution of 1366 X 768 and want to specify css styles only for this resolution .
Css @media rules only take into consideration min-width and max-width of the browser how do i target for specific resolution.
Upvotes: 1
Views: 2587
Reputation: 243
You can try this
@media screen and (min-width: 1500px) and (max-width: 1600px){
/*Your style */
}
Upvotes: 1
Reputation: 123377
Use width
and height
mediaqueries
@media (width: 1366px) and (height: 768px) {
:root { background: yellowgreen; }
}
to match a viewport of 1366x768
px
Anyway it's worth noting that, unless you are in fullscreen mode, that rule won't be applied because the UI of your browser takes some room, so the actual viewport can't be exactly the same of the chosen resolution.
Upvotes: 2
Reputation: 16251
Try this:
@media screen and (min-width: 1366px) and (max-width: 1366px)
and (min-height: 768px) and (max-height: 768px) {
/* style */
}
Upvotes: 2
Reputation: 1921
Use the resolution tag i.e. :
@media (resolution: 150dpi) {
p {
color: red;
}
}
More explantations and syntax here: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/resolution
Upvotes: 1