2

i'm trying to make menu to be position: fixed; when the browser width and height minimum or bigger than 1024/960 but for some reason when i'm resizing the screen height to more than 960 it doesn't work

here is the code i'm using:

    @media (min-width: 1024px) and (min-height: 960px) {
    ...
    }

i'm new to the @media any help would be appreciated!

SOoCreative
  • 213
  • 1
  • 3
  • 13
  • are you sure you're resizing just the height? because in your code you specify that both min-width and min-height MUST be obeyed for the rule to work. Also would be good to show which css properties are you trying to set, so showing more of your code would be appreciated. – Luciano Jul 14 '14 at 15:30
  • the css propirties that i'm trying to set is "position: fixed;height: 900px;" that's very weird but it works when i open popup window on testsize.com of any width or height that meet my rules however when i maximize the popup or i'm viewing it dirctly from the browser then the media queries gets disabled – SOoCreative Jul 14 '14 at 16:45

2 Answers2

0

have you looked at this answer?

with media queries you should use some kind of meta tag. also, try these meta tags:

<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport'/>
<meta name="viewport" content="width=device-width"/>

and try using

@media screen and (min-width: 1024px) and (min-height: 960px) {
***content***
}
Community
  • 1
  • 1
willi
  • 127
  • 7
0

for some reason it worked for me after replacing the AND with comma separate

before:

    @media only screen and (min-width : 1024px) and (min-height : 960px) 

after:

    @media only screen and (min-width : 1024px), (min-height : 960px)

any idea why?

SOoCreative
  • 213
  • 1
  • 3
  • 13
  • For the second I thought your solution actually works. But then I realized I had bad height value. I was looking at the body height instead of window height. After fixing my value it turned out everything works as expected (with `and` property instead of comma). – Mimoid May 03 '21 at 11:12
  • If we use comma(,) between two sizes, the code works if any of the size condition is true.. But if you use and, the code will work only if both the condition are true. – passionFinder Sep 19 '22 at 10:52