Issue with media queries and heights - css

I have two media queries like so:
#media(max-height: 1100px) and (min-width: 1200px) {
}
and this
#media(min-height: 750px) and (min-width: 1200px) {
}
My browser screen height is 779, What I am trying to do is apply css code if my screen height is 750px or less and width is 1200px or more. Also apply css code if my screen height is more than 750px and width is 1200px or more.
What am I doing wrong? Currently my #media(max-height: 1100px) and (min-width: 1200px) is overriding the #media(max-height: 1100px) and (min-width: 1200px) code.

Try the following, I believe you are missing a keyword or two... Also, if your desire is to have specific styling be applied on screens smaller than 750, you need to indicate a max-height of 750, not a min-height. (I did not change these below to reflect the max/min, only added in screen and).
#media screen and (max-height: 1100px) and (min-width: 1200px) {
}
#media screen and (min-height: 750px) and (min-width: 1200px) {
}

Related

Media Queries Height Pag css

#media screen and (min-width: 799px) and (max-width: 800px) {
}
I have a website whose resolution is 800x600 and another 800x400. The width is always the same, but not the height. How can I make the height of the page 600 in one and 400 in another?
You can use max-height in media queries to make a website responsive for height
1 use comma for different rule
#media screen and (max-width: 995px),
screen and (max-height: 700px) {
...
}
2.using and
#media screen and (max-width: 995px)and (max-height: 700px) {
...
}
you can assign different hight with this code
#media (min-height: 400px) and (max-height: 600px) and (min-width: 799px) and (max-width: 800px) { ... }

Apply css styles specific to screen resolution

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.
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
Try this:
#media screen and (min-width: 1366px) and (max-width: 1366px)
and (min-height: 768px) and (max-height: 768px) {
/* style */
}
Use width and height mediaqueries
#media (width: 1366px) and (height: 768px) {
:root { background: yellowgreen; }
}
to match a viewport of 1366x768 px
Codepen example
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.
You can try this
#media screen and (min-width: 1500px) and (max-width: 1600px){
/*Your style */
}

Responsive css same width different height

Lets say i want to make my div responsive for same width but different height.
Same width but if height is different, it will optimize the div different, like the code below but it is not working.
#media all and(min-width:1280px) and (height:768px){
#myDiv{height:84%}
}
#media all and(min-width:1280px) and (height:1200px){
#myDiv{height:97%}
}
Try this code
#media screen and (min-width: 1280px) and (max-height: 768px){
#myDiv{height:84%}
}
#media all and(min-width:1280px) and (max-height:1200px) and (min-height: 769px){
#myDiv{height:97%}
}

Multiple media queries for different screen sizes

I'm trying to set different image sizes according to the screen resolution, some of them work and some don't. Here's my Code:
#media screen and (max-width: 1280px) {#gallery-1 img {width:375px;}} // for 1280px screens
#media screen and (min-width: 1366px) and (max-width: 1439px){#gallery-1 img {width:375px;}} // for 1366px screens
#media screen and (min-width: 1440px) and (max-width: 1599px) {#gallery-1 img {width:428px;}} // for 1440px screens
#media screen and (min-width: 1600px) and (max-width: 1919px) {#gallery-1 img {width:434px;}} // for 1600px screens
#media screen and (min-width: 1920px) {#gallery-1 img {width:540px;}} // for 1920px screens
The code is not working at all for the 1366px and 1280px x 600px screen. 1280px x 960px works with the code for the 1366px. 1280px x 1024 works with the code for the 1440px. Can anybody please help? Thank you!
you don't need to set a maxwidth on your media queries as the next media query overrides it anyway. Try this:
#gallery-1 img {
width:375px;
}
#media screen and (min-width: 1366px) {
#gallery-1 img {width:375px;}
}
#media screen and (min-width: 1440px) {
#gallery-1 img {width:428px;}
}
#media screen and (min-width: 1600px) {
#gallery-1 img {width:434px;}
}
#media screen and (min-width: 1920px) {
#gallery-1 img {width:540px;}
}
Instead of using
#media screen and (min-width: 1366px) {
/* Styles go here */
}
Use media query differently like
#media (max-width: 1366px) and (min-width: 1441px) {
/* Styles go here */
}
this thing will specifically call out in which limit which styles should be applied.

Resolution with media screen

I´m using the following in css:
#media screen and (max-width: 400px){
.details-container {width: 121%;}
}
#media screen and (max-width: 640px){
.details-container {width: 201%;}
}
If i try a resolution under 400px, it takes the 640px css as reference, why?
A screen of 400px fits inside both your queries, that means it will get both values but the last one set will prevail per CSS cascading rules.
You can flip the order of the queries or specify a min-width in the second one
#media screen and (max-width: 400px){
.details-container {width: 121%;}
}
#media screen and (min-width: 401px) and (max-width: 640px){
.details-container {width: 201%;}
}

Resources