@@ -1553,14 +1553,15 @@ Mathematical Expressions: ''calc()''
1553
1553
1554
1554
1555
1555
1556
- The following example stacks two centered background images,
1557
- with one offset slightly from the other.
1556
+ The following example stacks two background images,
1557
+ with the first perfectly centered
1558
+ and the second offset 20px to the bottom and to the left of the first.
1558
1559
1559
1560
1560
1561
.foo {
1561
1562
background: url(top.png), url(bottom.png);
1562
1563
background-repeat: no-repeat;
1563
- background-position: calc(50% + 20px) calc(50% + 20px), 50% 50% ;
1564
+ background-position: 50% 50%, calc(50% + 20px) calc(50% + 20px);
1564
1565
}
1565
1566
1566
1567
@@ -1715,24 +1716,14 @@ Computed Value
1715
1716
they apply whenever a ''calc()'' expression contains percentages.
1716
1717
1717
1718
1718
- For example, 'background-position' has special behavior for percentage values, different from lengths:
1719
-
1720
-
1721
- .foo {
1722
- width: 200px;
1723
- background-image: url(bg.png);
1724
- background-position: left 50%;
1725
- /* different than: */
1726
- background-position: left 100px;
1727
- /* despite 50% of 200px being 100px */
1728
- }
1729
-
1719
+ For example,
1720
+ whereas
'font-size' computes percentage values at
computed value time
1721
+ so that
font-relative length units can be computed,
1722
+ 'background-position' has layout-dependent behavior for percentage values,
1723
+ and thus does not resolve percentages until used-value time.
1730
1724
1731
- Due to this, 'background-position' preserves the percentage in a ''calc()''
1732
- rather than resolving it directly into a length,
1733
- so that an expression like ''background-position: left calc(50% + 20px) center''
1734
- properly centers the background and then shifts it ''20px'' to the right,
1735
- rather than placing its left edge 20px off of center.
1725
+ Due to this, 'background-position' computation preserves the percentage in a ''calc()''
1726
+ whereas 'font-size' will compute such expressions directly into a length.
1736
1727
1737
1728
1738
1729
css-values-4/Overview.bs
Copy file name to clipboard Expand all lines: css-values-4/Overview.bs +7 -17 Lines changed: 7 additions & 17 deletions Original file line number Diff line number Diff line change @@ -2289,24 +2289,14 @@ Computed Value
2289
2289
2290
2290
2291
2291
2292
- For example, 'background-position' has special behavior for percentage values, different from lengths:
2293
-
2294
-
2295
- .foo {
2296
- width: 200px;
2297
- background-image: url(bg.png);
2298
- background-position: left 50%;
2299
- /* different than: */
2300
- background-position: left 100px;
2301
- /* despite 50% of 200px being 100px */
2302
- }
2303
-
2292
+ For example,
2293
+ whereas
'font-size' computes percentage values at
computed value time
2294
+ so that
font-relative length units can be computed,
2295
+ 'background-position' has layout-dependent behavior for percentage values,
2296
+ and thus does not resolve percentages until used-value time.
2304
2297
2305
- Due to this, 'background-position' preserves the percentage in a ''calc()''
2306
- rather than resolving it directly into a length,
2307
- so that an expression like ''background-position: left calc(50% + 20px) center''
2308
- properly centers the background and then shifts it ''20px'' to the right,
2309
- rather than placing its left edge 20px off of center.
2298
+ Due to this, 'background-position' computation preserves the percentage in a ''calc()''
2299
+ whereas 'font-size' will compute such expressions directly into a length.
2310
2300
2311
2301
2312
2302
You can’t perform that action at this time.