W3C home > Mailing lists > Public > www-style@w3.org > December 2012

Re: Media feature based on parent width instead of viewport/device width

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sun, 16 Dec 2012 20:26:22 -0800
Message-ID: <CAAWBYDDFU9yc+sjfXzOsOHV+g9PUoQYZ2XTOnF-W9Hge46e7Jw@mail.gmail.com>
To: Ben Callahan <ben@heysparkbox.com>
Cc: www-style list <www-style@w3.org>
On Sun, Dec 16, 2012 at 6:29 PM, Ben Callahan <ben@heysparkbox.com> wrote:
> Then, of course, there's the issue with the fact that the styled element's changes could impact the width of the element with the "selector query." That could cause some nastiness...

This is, in fact, the reason we can't ever do this.  Simple example:

<div id=parent>
  <div id=child></div>
</div>

#parent {
  float: left; //or anything else that makes it size based on its children
}
#child { width: 500px; }
@media (min-parent-width: 400px) {
  #child { width: 300px; }
}

When the parent is 500px wide, it must shrink to 300px wide, but then
it must grow to 500px wide, but then it must shrink to 300px wide...

This is a general problem, and one that can't be solved without
generic constraint solving and cycle breaking.

Even if we added such (we won't - it's too slow), it would make it
much more difficult (maybe impossible) for us to add new
interdependencies between properties, as they might create a cycle
that is then broken in a way that the author didn't expect, and mess
up the page.

So, sorry.  :/  I totally get how useful something like this would be,
but it simply can't be done in a reasonable manner with the way CSS is
now.  It's possible in the future that we may be able to add a more
restricted form of layout that can have this kind of interdependency
(its simplicity might make cycle detection + breaking more tractable),
but it won't allow arbitrary constraints.

~TJ
Received on Monday, 17 December 2012 04:27:11 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:03 GMT