forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.bs
More file actions
executable file
·776 lines (708 loc) · 34 KB
/
Copy pathOverview.bs
File metadata and controls
executable file
·776 lines (708 loc) · 34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
<pre class='metadata'>
Title: CSS Round Display Level 1
TR: http://www.w3.org/TR/css-round-display-1/
Shortname: css-round-display
Group: csswg
Level: 1
Status: ED
Work Status: Exploring
ED: https://drafts.csswg.org/css-round-display/
Previous Version: http://www.w3.org/TR/2015/WD-css-round-display-1-20150922/
Editor: Hyojin Song, LG Electronics, hyojin22.song@lge.com
Editor: Jihye Hong, LG Electronics, jh.hong@lge.com
Former Editor: Soonbo Han, LG Electronics, soonbo.han@lge.com
Abstract: This document describes CSS extensions to support a round display. It extends existing CSS features including Media Queries[[MEDIAQUERIES-4]], CSS Shapes[[CSS-SHAPES-1]], Borders[[CSS3-BORDER]], and Positioned Layout[[CSS3-POSITIONING]]. The extensions will help web authors to build a web page suitable for a round display.
</pre>
<h2 id="introduction">Introduction</h2>
<p>
Everything on the web is a rectangle. For example, the window content area in a web browser is a rectangle. Each HTML element follows the W3C box model and thus is also a rectangle. New devices with a round display are now emerging. The current web standards lack some features to support the devices as follows:
<ol>
<li>Lack of the capability to detect a round display</li>
<li>Lack of layout mechanisms suitable for a round display</li>
</ol>
In order to facilitate the use of the web on a round display, we need to rethink existing CSS features.
</p>
<p>
Current user agents are not capable of detecting the shape of a display so that authors cannot apply various layouts for a round display. To resolve the issue, we add the 'device-radius' media feature to Media Queries. The feature informs the web page of the property regarding the shape of the display.
</p>
<p>
To apply the shape of a display to content area, we extend the 'shape-inside' property of CSS Shapes. We also add the 'border-boundary' property to CSS Borders and introduce polar positioning for a better web design suitable for a round display.
</p>
<h2 id="terminology">Terminology</h2>
This specification follows the CSS property definition conventions from [[!CSS21]]. <br />
The detailed description of Media Queries is defined in [[MEDIAQUERIES-4]]<br />
The detailed description of CSS Shapes is defined in [[CSS-SHAPES-1]]<br />
The detailed description of Borders is defined in [[CSS3-BORDER]]<br />
The detailed description of Positioned Layout is defined in [[CSS3-POSITIONING]]<br />
<h2 id="extending-media-queries">Extending Media Queries for a round display</h2>
<p>
Media Queries [[MEDIAQUERIES-4]] define mechanisms to support media-dependent style sheets, tailored for different environments. We propose to extend Media Queries by adding the 'device-radius' media feature to support a round display. This will allow web authors to apply different styles to a web page on the rounded display.
</p>
<section>
<h3 id="device-radius-media-feature">The 'device-radius' media feature</h3>
To use different style sheets for a rectangle display and for a round display, media queries should support some properties to identify the display shape. The 'device-radius' media feature describes the property of rounded borders of a display.
<div class='example'>
This media query indicates that different style sheets will be applied depending on the display shape.
<pre>
<link media="screen and (device-radius: 0%)" rel="stylesheet" href="rectangle.css" />
<link media="screen and (device-radius: 50%)" rel="stylesheet" href="round.css" />
</pre>
<p>
By the mechanism of media queries, if the value of the 'device-radius' media feature is less than 50%, '<code>rectangle.css</code>' is applied. If it is 50%, '<code>round.css</code>' is applied.
</p>
</div>
<p>As in the '<code>border-radius</code>' property, the 'device-radius' media feature can describe various round shapes of displays, such as rectangle, regular circle, ellipse, and rectangle with round corners.
</p>
<pre class='descdef mq'>
Name: device-radius
Type: range
For: @media
Value: [ <<length>> | <<percentage>> ]
Percentage: Refer to corresponding dimension of the display
</pre>
<p class="note">
Note: To define a '<code>range</code>' type media feature, the feature may be written as a normal media feature, but with a '<code>min-</code>' or '<code>max-</code>' prefix on the feature name. '<code>min-</code>' or '<code>max-</code>' prefixes express 'greater or equal to' or 'smaller or equal to' constraints respectively.
</p>
<p>
The length or percentage value of the '<code>device-radius</code>' property defines a radius of a quarter ellipse in terms of the shape of the corner of the outer screen edge (This is similar to the '<code>border-radius</code>' property. See the 'border-radius' description). If the length is zero, the shape of screen is a rectangle, otherwise it is a rectangle with rounded corners or a circle or an ellipse. A percentage value of the '<code>device-radius</code>' is proportional to a width and a height of the screen, which have relevance to a horizontal radius and a vertical radius of the screen according to the length of width and height of the screen each. If the screen shape is the regular circle, '<code>device-radius</code>': 50% has a true value since a half of the width(=height) of the regular circle is the radius of the screen shape. In case of an ellipse with 200x100, '<code>device-radius</code>': 50% means that horizontal-radius of the screen is 100px and vertical-radius of the screen is 50px. It can't be described in length, not percentage. A negative value is not allowed.
</p>
<div class='example'>
The example below shows how a web page looks in the different shapes of displays. This is a simple clock written in HTML. (without 'device-radius')
<pre><!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="rectangle.css" />
</head>
<body>
<div id="clockLayer">
<div id="clockLayer">
<div id="date">2015/02/28 (SAT)</div>
<div id="time">10:11</div>
<div id="weather"><img src="cloudy.png" /></div>
</div>
</div>
</body>
</html>
</pre>
<div style="width: 700px; height: 380px; text-align:center">
<div style="float: left; width: 350px;">
<img alt="An image of a rectangle clock within a rectangle display" src="images/device_radius_clock_a.png">
<p>(A) Rectangle Display</p>
</div>
<div style="float: left; ">
<img alt="An image of a round clock within a rectangle display" src="images/device_radius_clock_b.png">
<p>(B) Round Display</p>
</div>
</div>
<div style="width: 700px">
<p class="caption">Devices where the 'device-radius' media feature is not applicable</p>
</div>
On the other hand, the example below shows how the 'device-radius' media feature works in the different shapes of displays. This is the same as the code above except for media queries usage. The 'device-radius' media feature can be used as follows:
<pre><!-- index.html -->
<head>
<link media="screen and (device-radius: 0%)" rel="stylesheet" href="rectangle.css" />
<link media="screen and (device-radius: 50%)" rel="stylesheet" href="round.css" />
</head>
</pre>
If this example code is loaded in a regular round display, '<code>round.css</code>' will be applied by the media queries mechanism. To render the clock properly, '<code>round.css</code>' could be written as follows.
<pre>
#clockLayer {
border-radius: 50%;
}
#clockInset {
border-radius: 50%;
}
#date {
text-align: center;
}
...
</pre>
<div style="width: 700px; height: 380px; text-align:center">
<div style="float: left; width: 350px;">
<img alt="An image of a rectangle clock within a rectangle display" src="images/device_radius_clock_a.png">
<p>(A) Rectangle Display<br>(w/ <code>device-radius: 0%</code>)</p>
</div>
<div style="float: left; ">
<img alt="An image of a round clock within a round display" src="images/device_radius_clock_c.png">
<p>(B) Round Display<br>(w/ <code>device-radius: 50%</code>)</p>
</div>
</div>
<div style="width: 700px">
<p class="caption">Devices where the 'device-radius' media feature is applicable</p>
</div>
</div>
<p class="note">Note: For other shapes, such as polygons, we need to extend the media features with additional parameters. The current features have limitations to support the diversity beyond round shapes. How can we express star-shaped polygons? (e.g. SVG syntax, etc.) Of course, there is a trade-off between simplicity and expressiveness.
</p>
<p class="issue">
Using 'device-radius' with just a single value (e.g. device-radius: 50%) is enough (for simplicity)? Otherwise, do we need to support all possible values the same as 'border-radius'?
</p>
<h2 id="aligning-content">Aligning content along the display border</h2>
<h3 id="shape-inside-property">The 'shape-inside' property</h3>
<p>
CSS Shapes [[CSS-SHAPES]] define the 'shape-inside' property that aligns contents along the edge of a possibly non-rectangular wrapping area. Web authors may use this feature to fit contents inside a round display. However, it can be challenging to specify the wrapping area to be identical to the shape of a display. To address such cases, 'shape-inside' is extended with a new value named '<code>display</code>', such an element having this value will have its content (or contained elements) aligned along the display border automatically.
</p>
<pre class='link-defaults'>
spec:css21; type:type; text:<uri>
</pre>
<pre class='propdef'>
Name: shape-inside
Applies to: block-level elements
Value: auto | outside-shape | [ <<basic-shape>> || shape-box ] | <<image>> | <code>display</code>
Initial: auto
Inherited: no
Media: visual
Computed value: computed lengths for <<basic-shape>>, the absolute URI for <<uri>>, otherwise as specified
Animatable: as specified for <<basic-shape>>, otherwise no
</pre>
<p>
The example below shows how the 'shape-inside' property works when it is set to '<code>display</code>'. Without using Media Queries, contents can be aligned within the display edge automatically.
</p>
<div class='example'>
<pre><style>
#container {
shape-inside: display;
// the same as circle(50% at 50%, 50%) in a regular round display
}
#green-box { float: left; }
#blue-box { float: right; }
</style>
<div id="container">
<p>
Some inline content
<img id="green-box" src="green-box.jpg" />
with a float left and float right, in a
<img id="blue-box" src="blue-box.jpg" />
simple box with a circle shape-inside.
</p>
</div>
</pre>
<br />
<div style="width: 500px; height: 380px; text-align:center">
<div style="float: left; width: 230px;">
<img alt="A layout of web contents without shape-inside:display" style="width: 230px" src="images/shape_inside_watch_a.png">
<p>(A) Without '<code>shape-inside</code>'</p>
</div>
<div style="float: left; width: 230px;">
<img alt="A layout of web contents with shape-inside: display" style="width: 230px" src="images/shape_inside_watch_b.png">
<p>(B) With '<code>shape-inside: display</code>'</p>
</div>
</div>
<div style="width: 500px">
<p class="caption">Align the content along the display border</p>
</div>
</div>
<p>
This property is specially useful for complex shapes (e.g. curved, stelliform, polygonal), that wouldn't be covered by <<basic-shape>> (i.e. circle() or ellipse()), allowing web authors to conveniently align contents with the display edge.
</p>
<p>
When a containing block is placed on one end of the display and the containing block has 'shape-inside: display', the descendant blocks of the containing block are basically put on the overlapping region between the containing block and the display area. The overlapping region's shape is mostly complicated shape, so it's difficult to define the shape using previous method like basic-shape. The figure 4 describes these circumstances as follows.
</p>
<div style="width: 500px;">
<img alt="An image of two examples to show the principle of shape-inside: display" style="width: 500px" src="images/shape_inside_a.png">
<p class="caption">Align part of the content along the display border</p>
</div>
<p class="issue">
What if content overflows? Clipping or scrolling?
</p>
<h2 id="drawing-borders">Drawing borders around the display border</h2>
<h3 id="border-boundary-property">The 'border-boundary' property</h3>
<p>
We add the 'border-boundary' property to set a boundary constraint that affects the borders of an element.
</p>
<pre class='propdef'>
Name: border-boundary
Applies to: all elements
Value: none | parent | display
Initial: none
Inherited: yes
Media: visual
</pre>
<p>
When the 'border-boundary' property on an element is set to '<code>parent</code>', additional borders of the element could be drawn where the element's area and the borders of its parent are met. When it is set to '<code>display</code>', additional borders could be drawn where the element's area and the borders of screen are met. The default value is '<code>none</code>', imposing no boundary constraint on the borders.
</p>
<div class='example'>
The example below shows how the 'border-boundary' property works on drawing borders. The result is shown in Figure 5B.
<pre><style>
#container {
border-boundary: display;
}
#redBox {
border: 5px red solid;
}
#greenBox {
border: 5px green solid;
}
#blueBox {
border: 5px blue solid;
}
</style>
<div id="container">
<div id="redBox"></div>
<div id="greenBox"></div>
<div id="blueBox"></div>
</div>
</pre>
<br />
<div style="width: 600px; text-align:center">
<div style="float: left; width: 300px;">
<img alt="An image of circle drawing border lines without border-boundary: display" style="width: 200px" src="images/border_boundary_a.png">
<p>(A) Without '<code>border-boundary</code>'</p>
</div>
<div style="float: left; width: 300px;">
<img alt="An image of circle drawing border lines with border-boundary: display" style="width: 200px" src="images/border_boundary_b.png">
<p>(B) With '<code>border-boundary: display</code>'</p>
</div>
</div>
<div style="width: 600px">
<p class="caption">Align the content along the display border</p>
</div>
</div>
<p class="note">Note: If the value of 'border-boundary' is parent or display, border lines of the element are actually just a visual effect. It triggers a layout for rendering in a general way, but in the above cases (border-boundary: parent|display), the layout doesn't occur and it only draws the border lines inward from the containing block's borders. With this situation, the borders might hide contents around the display edge.
</p>
<h2 id="positioning-content">Content positioning using polar coordinate system</h2>
<p>
Polar coordinate system is a two-dimensional coordinate system that describes the position of a point in a plane with a distance from a reference point and an angle from a reference direction. Elements could be placed along a circle or concentric circles, and the polar coordinate system is useful to handle such cases.
This section introduces polar positioning to support layout of elements in the polar coordinate system where the position of an element is determined by a distance from the center point within the containing element and an angle from the Y-axis.
The 'polar-angle' and 'polar-distance' properties specify the position of an element in polar coordinates.
When 'polar-distance' isn't auto, it means an element will be positioned by polar positioning not by the conventional two-dimensional positioning.
If one of the properties such as left, top, right, bottom isn't auto,
properties related to polar positioning are ignored.
</p>
<p class="note">
Note: In polar coordinate system, a pole is the reference point and points are described as been a certain distance from it, as also a certain angle from the polar axis. In mathematical theory, the polar axis is commonly defined as the positive direction of the x-axis, but we consider the polar axis as the positive direction of the y-axis position as other CSS specifications usually do. Therefore, when the 'polar-angle' value of an element is 0, the element is positioned on the y-axis. If the angle value of an element increases in the positive direction from 0, the element moves clockwise. The method to determine a direction using 'polar-angle' works the same way in [[CSS-VALUES]], <<angle>> value.
</p>
<p>
In conventional coordinate system used in the web, the origin is positioned in the upper left corner of a containing block. In comparison, the default origin of polar coordinates is the center point of a containing block. Therefore different methods are required to deploy and transform elements, or set margin/padding values when using polar coordinates.
An example as below shows the difference between the conventional coordinates and the polar coordinates when positioning elements.
</p>
<div class='example'>
The codes below show the difference between conventional coordinate system in the web and polar coordinate system when positioning elements.
When there are elements like below:
<pre>
<body>
<div id="box1"></div>
<div id="box2"></div>
</body>
</pre>
Then Figure 6A might be the result of
<pre><style>
#box1 {
position: absolute;
width: 100px;
height: 100px;
background-color: blue;
}
#box2 {
position: absolute;
width: 50px;
height: 50px;
background-color: green;
}
</style>
</pre>
Figure 6B might be the result of
<pre><style>
#box1 {
position: absolute;
polar-distance: 0%;
width: 100px;
height: 100px;
background-color: blue;
}
#box2 {
position: absolute;
polar-distance: 0%;
width: 50px;
height: 50px;
background-color: green;
}
</style>
</pre>
<br />
<div style="width: 700px; text-align:center">
<div style="float: left; width: 350px;">
<img alt="An image aligning two elements to containing block in the conventional coordinate system" style="width: 300px" src="images/polar_position_a.png">
<p>(A) With 'position: <code>absolute</code>;'</p>
</div>
<div style="float: left; width: 350px; ">
<img alt="An image aligning two elements to containing block in the polar coordinate system" style="width: 300px" src="images/polar_position_b.png">
<p>(B) With 'position: <code>absolute</code>; polar-distance: 0%;'</p>
</div>
</div>
<div style="width: 700px">
<p class="caption">Positioning elements in conventional coordinate system and polar coordinate system</p>
</div>
</div>
<h3 id="polar-angle-property">The 'polar-angle' property</h3>
The 'polar-angle' property specifies the angle from the Y-axis. This property is activated if the 'polar-distance' isn't <code>auto</code>.
<pre class='propdef'>
Name: polar-angle
Applies to: all elements
Value: <<angle>>
Initial: 0
Media: visual
Inherited: no
Percentages: N/A
Animatable: as <a href="http://www.w3.org/TR/css3-transitions/#animatable-types">angle</a>
</pre>
<h3 id="polar-distance-property">The 'polar-distance' property</h3>
The 'polar-distance' property determines how far elements are positioned from the origin of polar coordinates. Specifying a value except <code>auto</code> to 'polar-distance', it makes possible to position an element in polar coordinates.
<pre class='propdef'>
Name: polar-distance
Applies to: all elements
Value: [ <<length>> | <<percentage>> ] && contain?
Initial: 0
Media: visual
Inherited: no
Percentages: relative to distance from the origin of polar coordinates to edge of containing block
Animatable: as <a href="http://www.w3.org/TR/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a>
</pre>
<p>
The <code>'polar-distance'</code> specifies the distance between the origin of polar coordinates and the anchor point of the element.
<br>
Values have the following meanings:
<dl>
<dt><var><length></var></dt>
<dd>
A length value gives a fixed length between the origin of polar coordinates and the anchor point of element.
</dd>
</dl>
<dl>
<dt><var><percentage></var></dt>
<dd>
A percentage is relative to the distance from a point of contact which is made by the edge of containing block's shape and the gradient-line to the origin of polar coordinates. The starting point of the gradient-line is the origin of polar coordinates. And the value of the gradient of the line is polar angle value.
</dd>
</dl>
<dl>
<dt><var>contain</var></dt>
<dd>
Adjust polar-distance value of the positioned element which overflows shape of the containing block.
The main purpose of this value is avoiding overflow when positioning elements.
When overflowing occurs, the distance between the point of origin of polar coordinates and the anchor point of the element is reduced,
until there are 2 contact points or less between edge of shape of containing block and content block of the element.
</dd>
</dl>
</p>
<div class='example'>
Here are some examples.
The first example shows positioning elements with polar-distance not using extent keyword value. Some parts of elements are outside the boundary of the containing block's shape:
<pre><body>
<div style="position: absolute; polar-angle: 45deg; polar-distance: 100%"></div>
<div style="position: absolute; polar-angle: 180deg; polar-distance: 100%"></div>
</body>
</pre>
<div style="width: 500px; text-align: center">
<img src="images/polar_distance_a.png" style="width: 350px;"/>
</div>
In the second example, 'contain', the extent keyword value is added to the polar-distance value of each element to avoid overflowing.
<pre><body>
<div style="position: absolute; polar-angle: 45deg; polar-distance: 100% contain"></div>
<div style="position: absolute; polar-angle: 180deg; polar-distance: 100% contain"></div>
</body>
</pre>
<div style="width: 500px; text-align: center">
<img src="images/polar_distance_b.png" style="width: 350px;"/>
</div>
</div>
<p class="issue">
Would polar-distance property need auto value?
</p>
<div class='example'>
This example shows a way to align elements within the polar coordinate system.
<pre><body>
<div id="circle1" style="position: absolute; polar-angle: 0deg; polar-distance: 50%"></div>
<div id="circle2" style="position: absolute; polar-angle: 90deg; polar-distance: 20%"></div>
<div id="circle3" style="position: absolute; polar-angle: 225deg; polar-distance: 100%"></div>
</body>
</pre>
<div style="width: 400px; text-align: center">
<img alt="An image of three elements positioned to polar coordinates" src="images/polar_a.png" style="width: 200px; border: 1px #AAA solid; text-align: center"/>
<p class="caption">An example of polar positioning</p>
</div>
</div>
<p class="issue">
How to rotate the element itself with an axis from the element position to the central point of containing block? Is new property needed to support that at one time in polar coordinate system?
</p>
<p class="issue">
How to position items to the edge of the containing block without overflowing it? (<i>polar-anchor</i> could be suggested)
</p>
<p class="issue">
One of the profits of polar coordinate system is performance improvement. The significant performance improvement can be seen in animation using the polar coordinates. How to define animation in the polar coordinates? Is there any difference between the conventional coordinates and the polar coordinates when animate elements?
</p>
<p class="issue">
By 'polar-distance' property, a position of an element is specified based on the containing block's center. In other way, is the method of positioning elements by the distance based on the edge of the containing block needed?
</p>
<h3 id="polar-origin-property">The 'polar-origin' property</h3>
<p>
The 'polar-origin' property sets a point of origin for polar coordinate system.
<br><br>
Not only elements are positioned within the containing block according to the origin but also properties such as display, margin, and padding are affected by the origin. In conventional coordinate system, the origin of coordinate system implicitly set to upper left corner of the containing block. But in polar coordinates, it is general to specify the point of origin as the center point of the containing block. Also, there would be a situation that the other point in the containing block area need to be the origin.
</p>
<pre class='propdef'>
Name: polar-origin
Applies to: all elements
Value: <<position>>
Initial: 50% 50%
Media: visual
Inherited: no
Percentages: Refer to the size of containing block
Animatable: as <a href="http://www.w3.org/TR/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a>
</pre>
<p>
Where
<dl>
<b><position></b> = [
<br>
[ left | center | right | top | bottom | <var><percentage></var> | <var><length></var> ]
<br>
|
<br>
[ left | center | right | <var><percentage></var> | <var><length></var> ]
<br>
[ top | center | bottom | <var><percentage></var> | <var><length></var> ]
<br>
|
<br>
[ center | [ left | right ] [ <var><percentage></var> | <var><length></var> ]? ] &&
<br>
[ center | [ top | bottom ] [ <var><percentage></var> | <var><length></var> ]? ]
<br>
]
</dl>
Values are defined as follows:
<dl>
<dt><var><percentage></var></dt>
<dd>
A percentage for the horizontal offset is relative to the width of the containing block. A percentage for the vertical offset is relative to height of the containing block.
</dd>
</dl>
<dl>
<dt><var><length></var></dt>
<dd>
A length value gives a fixed length as the offset. The value for the horizontal and vertical offset represent an offset from the top left corner of the containing block.
</dd>
</dl>
<dl>
<dt><var>top</var></dt>
<dd>
Computes to 0% for the vertical position.
</dd>
</dl>
<dl>
<dt><var>right</var></dt>
<dd>
Computes to 100% for the horizontal position.
</dd>
</dl>
<dl>
<dt><var>bottom</var></dt>
<dd>
Computes to 100% for the vertical position.
</dd>
</dl>
<dl>
<dt><var>left</var></dt>
<dd>
Computes to 0% for the horizontal position.
</dd>
</dl>
<dl>
<dt><var>center</var></dt>
<dd>
Computes to 50% (left 50%) for the horizontal position if the horizontal position is not otherwise specified, or 50% (top 50%) for the vertical position if it is.
</dd>
</dl>
</p>
<p class="issue">
As it’s available to specify the point of origin for polar coordinates, properties such as 'margin', 'padding' would work different from the conventional coordinate system. We need different approaches to define those properties which are related to layout.
</p>
<p class="issue">
It becomes to use polar positioning no matter which value of 'position' property has, polar-origin would be used independently from polar positioning.
For this reason, an alternative naming without the <code>polar-</code> prefix for 'polar-origin' is needed.
</p>
<h3 id="polar-anchor-property">The 'polar-anchor' property</h3>
<p>
The 'polar-anchor' property sets an anchor point of the element. The anchor point specifies a position which is a representative point of the element. The anchor point could be set as any point within a content area of the element rather than being positioned to the upper left corner of the element by CSS box model.
With position: polar, the value of polar-distance is given to the distance between an anchor point and a center point of a containing block.
</p>
<pre class='propdef'>
Name: polar-anchor
Applies to: all elements
Value: <<position>>
Initial: 50% 50%
Media: visual
Inherited: no
Percentages: relative to width and height of an element
Animatable: as <<position>>
</pre>
<p>
Meanings of some keywords in <<position>> are different from those used in 'polar-origin' property.
<dl>
<dt><var><percentage></var></dt>
<dd>
A percentage for the horizontal offset is relative to width of content box area of the element. A percentage for the vertical offset is relative to height of content box area of the element. For example, with a value pair of '100%, 0%', an anchor point is on the upper right corner of the element.
</dd>
</dl>
<dl>
<dt><var><length></var></dt>
<dd>
A length value gives a length offset from the upper left corner of the element's content area.
</dd>
</dl>
</p>
<p>
Only with 'polar-angle' and 'polar-distance' to position elements, adjusting values of those properties for avoiding elements sticking out of the containing block is required. When the appropriate anchor point is given, there is no need to adjust 'polar-distance' value to avoid overflowing when positioning elements in the containing block.
</p>
<div class='example'>
This example shows an alignment of four elements with different anchor points positioned in a containing block.
<pre><style>
#item1 {
position: absolute;
polar-angle: 45deg;
polar-distance: 100%;
polar-anchor: right top;
}
#item2 {
position: absolute;
polar-angle: 135deg;
polar-distance: 100%;
polar-anchor: right bottom;
}
#item3 {
position: absolute;
polar-angle: 225deg;
polar-distance: 100%;
polar-anchor: left bottom;
}
#item4 {
position: absolute;
polar-angle: 315deg;
polar-distance: 100%;
polar-anchor: left top;
}
</style>
<body>
<div id="item1"></div>
<div id="item2"></div>
<div id="item3"></div>
<div id="item4"></div>
</body>
</pre>
<div style="width: 400px; text-align: center">
<img alt="An image of four elements with different anchor points positioned in a containing block" src="images/polar_anchor.png" style="width: 300px; text-align: center"/>
<p class="caption">An example of 'polar-anchor'</p>
</div>
</div>
<p class="issue">
Is '<code>auto</code>' needed for value of 'polar-anchor'?
</p>
<p class="issue">
How to solve overflowing when an element has 'polar-anchor' value as '<code>top</code>', 'polar-angle' value is 0deg, and 'polar-distance' is equal to the distance from center to edge of containing block?
</p>
<p class="issue">
It becomes to use polar positioning no matter which value of 'position' property has, polar-anchor would be used independently from polar positioning.
For this reason, an alternative naming without the <code>polar-</code> prefix for 'polar-anchor' is needed.
</p>
<p class="issue">
How can the margin be applied to an element when <code>polar-origin: 50% 50%</code> and <code>polar-anchor: 50% 50%</code>?
<br>
Which would be a base point for applying it between the upper left corner or center of a containing block?
With the former, the position of the element changes when the value of the margin changes, while with the latter, the margin value doesn't affect the position of the element.
</p>
<p class="issue">
Can 'polar-anchor' be replaced by 'margin-top' and 'margin-left'?
<br>
There are several differences between 'polar-anchor' and 'margin-left' & 'margin-top'.<br>
In case of 'margin-left' & 'margin-top', percentages resolve to the width of the element itself.
but in case of 'polar-anchor', percentage resolves to the width and height of a containing block of the element.
</p>
<h3 id="2d-rotation-transform-function">2D Rotation Transform Function for self-rotating elements in polar coordinates</h3>
<p>
When elements are positioned in polar coordinates, there are many usecases which show the elements rotated toward the origin of polar coordinates. In such cases, degree of rotation has to be specified in the 2d rotation function for each element. But when using the keyword value instead of the <<angle>> value, the calculation of accurate rotation degree may be omitted.
<br><br>
The two-dimensional rotation function <code><a href="http://www.w3.org/TR/css3-transforms/#funcdef-rotate">'rotate(<angle>)'</a></code> used in polar coordinates is extended as follows:
<dl><dd>
<code><a href="http://www.w3.org/TR/css3-transforms/#funcdef-rotate">rotate()</a> = rotate( <<angle>> | polar-angle | polar-angle-reverse)</code>
</dd></dl>
Values have the following meanings:
<dl>
<dt><var>polar-angle</var></dt>
<dd>
Rotate an element by the value of 'polar-angle' property.
</dd>
</dl>
<dl>
<dt><var>polar-angle-reverse</var></dt>
<dd>
Rotate an element by the angle of the 'polar-angle' property plus 180 degrees.
</dd>
</dl>
</p>
<p class="note">
Note: polar-angle and polar-angle-reverse keywords resolve to angle values when determining the computed value of transform property.
It makes possible to define an animation such as transforming between rotate(0deg) and rotate(polar-angle).
If there is an animation using 'polar-angle' property, polar-angle value and polar-angle-reverse value track the changes in the value of the 'polar-angle' property.
</p>
<div class='example'>
This example shows how the keyword value works in the 2d rotation function.
<pre><style>
#item1 {
position: absolute;
polar-angle: 0deg;
polar-distance: 90%;
transform: rotate(polar-angle);
}
#item2 {
position: absolute;
polar-angle: 45deg;
polar-distance: 90%;
transform: rotate(polar-angle);
}
#item3 {
position: absolute;
polar-angle: 135deg;
polar-distance: 90%;
transform: rotate(polar-angle-reverse);
}
#item4 {
position: absolute;
polar-angle: 180deg;
polar-distance: 90%;
transform: rotate(polar-angle-reverse);
}
#item5 {
position: absolute;
polar-angle: 225deg;
polar-distance: 90%;
transform: rotate(polar-angle-reverse);
}
#item6 {
position: absolute;
polar-angle: -45deg;
polar-distance: 90%;
transform: rotate(polar-angle);
}
</style>
<body>
<div id="item1">1</div>
<div id="item2">2</div>
<div id="item3">3</div>
<div id="item4">4</div>
<div id="item5">5</div>
<div id="item6">6</div>
</body>
</pre>
<div style="width: 500px; text-align: center">
<img alt="An image of extended 2d rotate function" src="images/2d_rotate_function.png" style="width: 250px; text-align: center"/>
<p class="caption">An example of the extension for 2d rotate function</p>
</div>
</div>
<h2 class="no-num" id="acks">
Acknowledgements</h2>
This specification is made possible by input from
Florian Rivoal,
Sangjoe Park,
and the CSS Working Group members,
with special thanks to
Dongyoung Lee and Soonbo Han for creating the initial proposal.
Thanks also to Adenilson Cavalcanti for editorial input.