W3C home > Mailing lists > Public > www-style@w3.org > February 2013

Re: [css3-values] viewport units (vw/vh/vmin/vmax) and @page rules

From: Simon Sapin <simon.sapin@kozea.fr>
Date: Sun, 24 Feb 2013 23:44:32 +0100
Message-ID: <512A97D0.6000303@kozea.fr>
To: www-style@w3.org
Le 15/11/2012 14:20, Simon Sapin a écrit :
> Le 11/11/2012 22:14, L. David Baron a écrit :
>> So, if we have:
>>
>>     @page {
>>       margin-left: 10vw;
>>     }
>>
>> should:
>>     (1) the user-agent try to solve the relevant equations to find a
>>     valid size for the page box given the margins?  (This seems like
>>     it might be doable in a few of the simple cases, but certainly
>>     isn't solvable in general.)
>>
>>     (2) the declaration be ignored?
>>
>>     (3) the declaration be treated as some other particular value
>>     (e.g., '0', 'auto')?
>
> A concrete proposal for 2:
>
> Viewport units (vw/vh/vmin/vmax) are not allowed in the following
> properties:
>
> - size
> - margin-*
> - border-*-width
> - padding-*
> - width
> - height
>
> when used directly inside @page. (They are allowed in page-margin boxes
> or future at-rules inside @page.) If used anyway, the declaration is
> invalid and ignored with the usual cascading rules.
>
>
> This covers the most obvious cases, but is not enough. Consider:
>
>       @page { font-size: 1vw; width: 50em }
>
> This one can be fixed by adding font-size to the list of properties
> above, or adding font-based units to the list of forbidden units.
>
>
> Also, the page context inherits from the root element:
>
>       :root { width: 50vw }
>       @page { width: inherit }
>
>       :root { width: auto; margin: 10vw }
>       @page { width: inherit }
>
>       :root { font-size: 1vw }
>       @page { width: 50em }
>
> I don’t know what to do about these, short of having the page context
> *not* inherit from anything.
>
>
> Ideas?

This issue is https://www.w3.org/Style/CSS/Tracker/issues/315


GPHemsley points out an interesting point on IRC:

With the changes I just made to the 'page' property (so that the first 
page can be "named") the full cascade on elements is required to 
determine what is the "type" of the first page.

Consider:

     @page { size: A4 portrait }
     @page wide { size: A4 landscape }
     html, body { /* page: auto */ }
     html > body > table:first-child { page: wide }

If there is a matching table, the first page is "wide" and viewport 
units change!


Another idea from GPHemsley is to look at @viewport. There, viewport 
units are based on the "initial viewport".

@page could do the same: viewport units inside @page are based on the 
UA’s default page size and margins, ignoring any stylesheet. Same as the 
'width' and 'height' Media Queries.


So, proposal:

* Viewport units in the page context (but maybe not inside margin 
at-rules) refer to the UA’s default page size, ignoring any stylesheet.

* Viewport units are based not on the first page, but on an hypothetical 
page that does not match any page name or page pseudo-
class. (In other words, only consider @page rules without a page selector.)

* That hypothetical page does not inherit from the root element.
Alternative: @page never inherits from the root.


Would that work?

-- 
Simon Sapin
Received on Sunday, 24 February 2013 22:45:01 GMT

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