I have a crazy web app going on, with all kinds of dynamic widths and heights and vertically centered stuff. It looks great on just about every resolution except 1366x768 and 1280x800. I know how to fix it with some CSS rule overrides. I want to target these SPECIFIC resolutions ONLY (meaning I do NOT want to target 1280x1024 with a min-width: 1280 and max-width: 1280). Please don't lecture me about best practices and stuff, I need a quick and dirty answer.
How can I do this? Surprisingly Google isn't giving me any good results.
Normally, the text size will be 14px. However since we applied a media query, it will change to 16px when a device has a maximum width of 480px or less. Important: Always put your media queries at the end of your CSS file. If we don’t apply a media type, the @ media rule selects all types of devices by default.
Media queries are used for the following: To conditionally apply styles with the CSS @media and @import at-rules. To target specific media for the <style>, <link>, <source>, and other HTML elements with the media= attribute. To test and monitor media states using the Window.matchMedia() and MediaQueryList.addListener() JavaScript methods.
What is a Media Query? A Media query is a CSS3 feature that makes a webpage adapt its layout to different screen sizes and media types. We can target different media types under a variety of conditions.
@media (max-width: 12450px) {... If you create a media feature query without specifying a value, the nested styles will be used as long as the feature's value is not zero (or none , in Level 4). For example, this CSS will apply to any device with a color screen:
You could use:
@media screen and (min-width: 1280px) and (max-width: 1280px)
and (min-height: 800px) and (max-height: 800px) {
/* Crazy CSS overrides here */
}
/* Second variant left as an exercise for the reader */
However, you will probably do better in the long run if you take the time to refactor now - later never seems to get here.
Try this:
@media screen and (max-width: 1280px) and (max-height: 800px)
{
/*write CSS here*/
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With