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

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

From: Ben Callahan <ben@heysparkbox.com>
Date: Sun, 16 Dec 2012 21:29:53 -0500
Message-ID: <CADcYynQguvz89LQuahAXzQ+fySUQjsU1MGi9xiCPCCza6Uxg=Q@mail.gmail.com>
To: www-style@w3.org
Hello all,

I'm new to this list, so please forgive me if I'm opening a fresh wound
with this suggestion. I have searched through the archives, but haven't
found much conversation about this.

I feel like there could be some significant benefits in providing the
ability for us to query the width of a parent element in the media feature
portion of a media query. Initially I thought it could look something like

@media (min-parent-width: 30em) {
   p.style-me { /* styles for when the width of the parent of this "p" is
greater than or equal to 30em */ }

Or nested like this:

p.style-me {
   @media (min-parent-width: 30em) {
      /* styles */

However, these don't really address the issue because they're dependent on
the relationship between the parent and child. What I really want is the
ability to style something based on any other elements properties. Maybe I
want the font-size of a list item to be smaller when a specific "aside"
element is less than 30em.

Andy Hume and Jeremy Keith came up with syntax like this:

div.some-div @selector (min-width: 30em) {
      /* styles */

This is pretty darn flexible.

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...

Anyway, here's Andy's article<http://blog.andyhume.net/responsive-containers/>.
Others have created JS
well. There are so many times when I wish we had this ability. I think
it could allow us to create some incredibly modular styles.

Thanks for your patience with this noob.


Ben Callahan
Sparkbox, President

411 East Fifth Street

Dayton, OH 45402

office  937 401 0915

fax  877 253 6954
Received on Monday, 17 December 2012 02:30:22 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:06 UTC