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

Re: ceil support for calculated units?

From: Simon Sapin <simon.sapin@exyr.org>
Date: Tue, 11 Jun 2013 13:51:10 +0100
Message-ID: <51B71D3E.2060806@exyr.org>
To: Netmosfera <netmosfera@gmail.com>
CC: www-style list <www-style@w3.org>
Le 11/06/2013 06:24, Netmosfera a écrit :
> I don't know if it was already suggested, but...
>
> <!-- let's say the window is 801px wide -->
> <div style="width:801px">
>       <div style="width:50%;background:red;float:left;">a</div>
>       <!-- annoying pixel line in the middle -->
>       <div style="width:50%;background:red;float:right;">b</div>
> </div>
>
> <div style="width:801px">
>       <div style="width:50%;background:red;float:left;">a</div>
>       <div style="width:ceil(50%);background:red;float:right;">b</div>
> </div>
>
> "width:floor(50%)" is the default behavior and it equals to write
> "width:50%" so it isn't really needed
>
> I haven't more use cases, do you have any, especially for newer layout
> modules?


In every case here, the used value for 'width' is 801.5px. Note that 
this is CSS pixels, which may or may not be the same as device pixels. 
For example, some newer high-resolution devices use 2 device pixels per 
CSS pixel. (In Media Queries terms, resolution: 2ddpx)

It is what CSS calls the *actual* value that may or may not be rounded 
to whole device pixels, but that rounding is completely unspecified by 
CSS. I don’t think we want to provide control over it.


However, I believe that your use case is covered by Flexbox. There 
shouldn’t be single-pixel lines between flex items because of rounding.

-- 
Simon Sapin
Received on Tuesday, 11 June 2013 12:51:34 UTC

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