css - What can you put into a media query expression? -
in following media query styles defined in style declaration applied when viewing via screen , when minimum width 480px wide (correct?):
@media screen , (min-width: 480px) { #leftsidebar {width: 200px; float: left;} #main {margin-left:216px;} }
what else can put expression statement?
for example, condition on url fragment:
@media screen , (document.location.hash=="#about") { #leftsidebar {width: 200px; float: left;} #main {margin-left:216px;} } @media screen , (document.location.hash=="#services") { #leftsidebar {width: 200px; float: left;} #main {margin-left:216px;} } @media screen , (document.location.hash=="#contact") { #leftsidebar {width: 200px; float: left;} #main {margin-left:216px;} }
what can put media query expression?
you can put media feature. available media features documented in spec (mq3, mq4).
for example, condition on url fragment:
that's unfortunately not possible media queries, though sound interesting use case without having resort applying url fragment html
or body
or other arbitrary wrapper element. i'm not sure how jive media queries though, given url fragment isn't part of device media per se, part of url. feature better suited in own at-rule (such now-gone @document
) or part of selectors.
the closest pure-selector alternative can think of (prepending :root:has(#about:target)
, :root:has(#services:target)
, etc every selector) in selectors 4 , not available css, that's real bummer.
Comments
Post a Comment