css3 - What does @media screen and (max-width: 1024px) mean in CSS? -
i found piece of code in css file inherited, can't make sense out of it:
@media screen , (max-width: 1024px){ img.bg { left: 50%; margin-left: -512px; } }
specifically, happening on first line?
that’s media query. prevents css inside being run unless browser passes tests contains.
the tests in media query are:
@media screen
— browser identifies being in “screen” category. means browser considers desktop-class — opposed e.g. older mobile phone browser (note iphone, , other smartphone browsers, do identify being in screen category), or screenreader — , it’s displaying page on-screen, rather printing it.max-width: 1024px
— width of browser window (including scroll bar) 1024 pixels or less. (css pixels, not device pixels.)
that second test suggests intended limit css ipad, iphone, , similar devices (because older browsers don’t support max-width
in media queries, , lot of desktop browsers run wider 1024 pixels).
however, apply desktop browser windows less 1024 pixels wide, in browsers support max-width
media query.
here’s media queries spec, it’s pretty readable:
Comments
Post a Comment