W3C home > Mailing lists > Public > www-style@w3.org > January 2011

[css3-background] Question on background-repeat: round

From: <Cathy.Chan@nokia.com>
Date: Fri, 14 Jan 2011 19:54:42 +0000
To: <www-style@w3.org>
Message-ID: <D66EA3180FEC4248B33155A2C7E6313B15E9DF@008-AM1MPN1-016.mgdnok.nokia.com>
The spec provides the following formula for computing the background size when background-repeat is ‘round’ for one or both dimensions (http://www.w3.org/TR/css3-background/#the-background-size):

If X ≠ 0 is the width of the image after step one and W is the width of the background positioning area, then the rounded width X' = W / round(W / X) where round() is a function that returns the nearest natural number (integer greater than zero).

My understanding of the "nearest natural number" is that it could be smaller than or larger than the given number. Thus, 2.4 should round (down) to 2, whereas 2.7 should round (up) to 3.

However, the examples seem to imply that rounding is always in the "up" direction to the next natural number, which is not necessarily the nearest.

For example, the last example in Example XIII above the formula:

The following example rounds the height of the image to 25%, down from the specified value of 30%. At 30%, three images would fit entirely and a fourth only partially. After rounding, four images fit. The width of the image is 20% of the background area width and is not rounded. 
p {
    background-image: url(chain.png);
    background-repeat: no-repeat round;
    background-size: 20% 30% }

At 30%, 3.33 images would have been in a row. Shouldn't the "nearest natural number" be 3 instead of 4?

Similarly, the third example in Example XIV below the formula:

In the following example, the background is shown with a width of 3em or slightly smaller, so that it fits a whole number of times in the width of the background. The height is scaled proportionally to keep the original aspect ratio: 
div {
  background-image: url(image3.png);
  background-repeat: round repeat;
  background-size: 3em auto }

If rounding could go in either direction, the background width could be 3em, slightly smaller, *or slightly larger*.

So, which is correct, the formula or the examples? Or am I missing something completely?

Thanks and regards, Cathy.
Received on Friday, 14 January 2011 19:57:18 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:54 UTC