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

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 UTC