Level: 1 Status: ED Work Status: Exploring ED: https://drafts.csswg.org/css-round-display/ Shortname: css-round-display TR: https://www.w3.org/TR/css-round-display-1/ Previous Version: https://www.w3.org/TR/2015/WD-motion-1-20150409/ Group: csswg Link Defaults: css-shapes-1 (type), css-transforms-1 (property) transform/transform-origin Previous Version: https://www.w3.org/TR/2016/WD-css-round-display-1-20160301/ Previous Version: https://www.w3.org/TR/2015/WD-css-round-display-1-20150922/ Editor: Hyojin Song, LG Electronics, hyojin22.song@lge.com, w3cid 54503 Editor: Jihye Hong, LG Electronics, jh.hong@lge.com, w3cid 79168 Former Editor: Soonbo Han, LG Electronics, soonbo.han@lge.com Abstract: Motion paths allow authors to animate any graphical object along an author specified path.
url: https://svgwg.org/svg2-draft/shapes.html#TermShapeElement; type: dfn; spec: SVG2; text: shape element url: https://www.w3.org/TR/SVG11/struct.html#DefsElement; spec: SVG11; type: element; text: defs
Conventionally, web pages have been shown through a rectangular screen such as PC, tablet, and smart phone. 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.
Nowadays, devices come in varied shapes of the displays.
It needs to consider the shape of the display when implementing web pages on devices.
However, current web standards lack some features to support the devices as follows:
The 'device-radius' media feature is added to Media Queries.
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, 'device-radius' informs the web page of the property regarding the shape of the display.
To apply the shape of a display to content area, we extend the 'shape-inside' property of CSS Shapes. The position of the element which is overflowed from the display is adjusted inside the display when using this property even if the authors don’t know the exact shape of the display.
We also add the 'border-boundary' property to CSS Borders. The borders of the element can be drawn along the edge of the display even if the element is overflowed.
For the better web design suitable for a round display, we introduce polar positioning.
In conventional positioning method, the Cartesian coordinates, elements are positioned by offsets in x-axis and y-axis. But, we suggest a method to position elements with specifying the distance and angle from the origin point of coordinates.
This module provides features such as:
* Detecting the rounded display
* Aligning contents in the display’s shape
* Drawing borders along the display’s edge
* Positioning elements in polar coordinates
Name: shape Type: discrete For: @media Value: rect | round
Note: To define a 'discrete' type media feature, the feature is evaluated in a boolean context.
The 'shape' media feature describes the general shape of the targeted display area of the output device. It accepts the following values:<!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>
(A) Rectangle Display
(B) Round Display
<!-- index.html --> <head> <link media="screen and (shape: rect)" rel="stylesheet" href="rectangle.css" /> <link media="screen and (shape: round)" rel="stylesheet" href="round.css" /> </head>If this example code is loaded in a round display, 'round.css' will be applied by the media queries mechanism.
(A) Rectangle Display
(w/ shape: rect
)
(B) Round Display
(w/ shape: round
)
Note: There are cases when the UA may know the shape even in the absence of OS APIs. For example, when rendering to PDF, the shape is known to be a rectangle, so 'shape: rect' evaluates to ''true'' while ''shape: round'' to ''false''
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.
Name: viewport-fit For: @viewport Value: auto | contain | cover Initial: auto Percentages: N/A Computed value: as specifiedThe initial viewport is seen through the physical screen of the device. On rounded screen, the part of the page that’s currently shown on-screen is round but the viewport is rectangular. Because of this, some part of the page is clipped.
@viewport (viewport-fit: contain) { /* CSS for the rectangular design */ }
viewport-fit: contain
'
@viewport (viewport-fit: cover) { /* CSS for the rectangular design */ }
viewport-fit: cover
'
display
', such an element having this value will have its content (or contained elements) aligned along the display border automatically.
spec:css21; type:type; text:
Name: shape-inside Applies to: block-level elements Value: auto | outside-shape | [ <The example below shows how the 'shape-inside' property works when it is set to '> || shape-box ] | < > | display
Initial: auto Inherited: no Computed value: computed lengths for <>, the absolute URI for < >, otherwise as specified Animatable: as specified for < >, otherwise no
display
'. Without using Media Queries, contents can be aligned within the display edge automatically.
<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>
(A) Without 'shape-inside
'
(B) With 'shape-inside: display
'
What if content overflows? Clipping or scrolling?
Name: border-boundary Applies to: all elements Value: none | parent | display Initial: none Inherited: yesWhen the 'border-boundary' property on an element is set to '
parent
', 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 'display
', additional borders could be drawn where the element's area and the borders of screen are met. The default value is 'none
', imposing no boundary constraint on the borders.
<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>
(A) Without 'border-boundary
'
(B) With 'border-boundary: display
'
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.
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 conventional coordinates used in web is the Cartesian coordinate system, but using 'polar-distance' or 'polar-angle' enables positioning an element in the polar coordinate system. The 'polar-angle' and 'polar-distance' properties specify the angular value and distance of an element from the origin in polar coordinates.
<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>
An example of polar positioning
In conventional coordinate system used for positioning an element in a containing block, the offset of the element is applied depending on the edges of the element’s containing block. In comparison, the default origin of polar coordinates is positioned at the center point of a containing block. The position for the origin point can be set by 'polar-origin'.
Name: polar-angle Applies to: all elements Value: <> Initial: 0 Inherited: no Percentages: N/A Animatable: as angle
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-3]], <
Name: polar-distance Applies to: all elements Value: [ <> | < > < >? ] && contain? Initial: 0 Inherited: no Percentages: relative to distance from the origin of polar coordinates to edge of containing block Animatable: as length, percentage, or calc
The 'polar-distance' specifies the distance between the origin of polar coordinates and the anchor point of the element.
Values have the following meanings:
Note: When the origin of polar coordinates is at one of the corners of the containing block, the closest side takes the edge which meets with the origin. Even if the offset given by <
<div style="position: absolute; width: 40px; height: 30px;"> <div id = “circle1” style="position: absolute; width: 4px; height: 4px;"></div> <div id = “circle2” style="position: absolute; width: 4px; height: 4px;"></div> </div>
Specifying different <size> value for the same <percentage> value makes a difference in the positions of the elements.
The style below is for the (A),<style> #circle1 { polar-origin: 10px 15px; polar-angle: 0deg; polar-distance: 100% closest-side; } #circle2 { polar-origin: 10px 15px; polar-angle: 90deg; polar-distance: 100% closest-side; } </style>And the next definition is for the (B)
<style> #circle1 { polar-origin: 10px 15px; polar-angle: 0deg; polar-distance: 100% closest-corner; } #circle2 { polar-origin: 10px 15px; polar-angle: 90deg; polar-distance: 100% closest-corner; } </style>
(A) With closest-side
(B) With closest-corner
Using <size> with <percentage> for polar-distance
<body> <div style="position: absolute; polar-angle: 45deg; polar-distance: 100%"></div> <div style="position: absolute; polar-angle: 180deg; polar-distance: 100%"></div> </body>
<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>
The 'polar-origin' property establishes the point of origin for coordinate system. It sets the horizontal and vertical representative point at which the offset values of the element is applied.
Name: polar-origin Applies to: all elements Value: auto | <> Initial: auto Inherited: no Percentages: Refer to the size of containing block Animatable: as length, percentage, or calc
Values are defined as follows:
#item1 { polar-origin: auto; polar-distance: 10px; polar-angle: 90deg; }
"polar-origin: auto" is the same result with "polar-origin: center"
#item2 { polar-origin: auto; left: 10px; }
"polar-origin: auto" is the same result with "polar-origin: top left"
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.
When 'polar-origin' is not auto
, it needs to be decided whether 'top', 'right', 'bottom', and 'left' properties are ignored or interpreted somehow.
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. The value of 'polar-distance' is the distance between an anchor point and the origin point of coordinates.
Name: polar-anchor Applies to: all elements Value: <> Initial: 50% 50% Inherited: no Percentages: relative to width and height of an element Animatable: as < >
Meanings of some keywords in <
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.
<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>
An example of 'polar-anchor'
Is 'auto
' needed for value of 'polar-anchor'?
The alternative naming without the polar- prefix for 'polar-origin' and 'polar-anchor' is needed. When it becomes to use polar positioning regardless of the value of the position property, 'polar-origin' and 'polar-anchor' would be used independently from polar positioning.
How can the margin be applied to an element when polar-origin: 50% 50%
and polar-anchor: 50% 50%
?
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.
Can 'polar-anchor' be replaced by 'margin-top' and 'margin-left'?
There are several differences between 'polar-anchor' and 'margin-left' & 'margin-top'.
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.
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 <
The two-dimensional rotation function
'rotate(<angle>)'
used in polar coordinates is extended as follows:
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.
<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>
An example of the extension for 2d rotate function
polar
value of 'position'. Polar positioning applies to absolute/fixed/sticky/relative positioned elementsThis specification is made possible by input from Dong-Young Lee, Soonbo Han, Florian Rivoal, Joone Hur, Kang-Soo Seo, Sangjo Park, Woojun Jung, Chisoon Jeong, Yunbum Sung, Alan Stearns, Brad Kemper, and the CSS Working Group members. Thanks also to Adenilson Cavalcanti for editorial input.