W3C home > Mailing lists > Public > www-style@w3.org > April 2014

Re: [css-variables][css3-mediaqueries] using variables in media query expressions

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 15 Apr 2014 09:47:42 -0700
Message-ID: <CAAWBYDBA2pJ+X_9tVKFGOsehwpb==H7Awe1OqTnnVm=-dS64BQ@mail.gmail.com>
To: Cameron McCormack <cam@mcc.id.au>
Cc: www-style list <www-style@w3.org>
On Mon, Apr 14, 2014 at 8:00 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> I saw somebody want to use CSS Variables with media queries, like this:
>   :root {
>     --large: 800px;
>   }
>   @media screen and (max-width: var(--large)) {
>     /* rules to implement some responsive design */
>   }
> That seems like a reasonable thing to want to do.  Can we define that
> variables in @media rules are resolved using the computed style of the root
> element?

It's not a reasonable thing to do - there's no custom property to draw
them from, and as Boris points out, no arbitrary choice you make will
work unless you just prevent all custom properties within an @media.

They want custom media queries, which I'm beginning to spec in the MQ
spec now: <http://dev.w3.org/csswg/mediaqueries/#custom-mq>.

Received on Tuesday, 15 April 2014 16:48:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:41 UTC