Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

media query max-width relates to the view port size or the windows size?

I'm wondering if the max-width of a media query is relates to the view port size or the windows size?

for example , I have this media query:

@media screen and (max-width: 360px){}

will this media query be in action when the view port size is 360px or the windows size 360px?

like image 504
Lir An Avatar asked Nov 01 '12 17:11

Lir An


People also ask

How does @media max width work?

The min-width and max-width are media features that correspond to a certain media type that has been specified in the media query. The min-width specifies the minimum screen width of a specific device, meanwhile, The max-width media feature states the maximum screen width of a specific device.

How do you write a media query for max width?

Combining media query expressions Max-width and min-width can be used together to target a specific range of screen sizes. @media only screen and (max-width: 600px) and (min-width: 400px) {...} The query above will trigger only for screens that are 600-400px wide.

Can media queries determine the size of a viewport?

Media queries can be used to check many things, such as: width and height of the viewport. width and height of the device. orientation (is the tablet/phone in landscape or portrait mode?)

What is max width in media query?

Max-width : max -width means less than or equal to the width specified in that media query. So, in above example element which has “#ButtonWrapper” as the Id, will get width of 70% to all the screens widths which are less than or equal to 1024px.


1 Answers

It's the viewport. This is stated in the spec:

The ‘width’ media feature describes the width of the targeted display area of the output device. For continuous media, this is the width of the viewport (as described by CSS2, section 9.1.1 [CSS21]) including the size of a rendered scroll bar (if any).

This also applies to sub-viewports within the main browser viewport, such as those of framesets and iframes. So if an iframe has a width of 360px or less, your media query will also apply within that iframe.

like image 85
BoltClock Avatar answered Sep 22 '22 01:09

BoltClock