Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Targeting Specific Resolution CSS Media Query [duplicate]

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.

like image 387
LOLapalooza Avatar asked Jan 09 '13 16:01

LOLapalooza


People also ask

What is the text size for media queries in CSS?

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.

How do I use mediaquerylist in CSS?

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 CSS3 media query?

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.

What is the max width of a media feature query?

@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:


2 Answers

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.

like image 100
Sean Vieira Avatar answered Oct 08 '22 10:10

Sean Vieira


Try this:

@media screen and (max-width: 1280px) and (max-height: 800px)
{
/*write CSS here*/
}
like image 26
Seema Barate Avatar answered Oct 08 '22 10:10

Seema Barate