Title: CSS Round Display Level 1 Shortname: css-round-display Group: csswg Level: 1 Status: ED ED: http://dev.w3.org/csswg/css-round-display/ Editor: Hyojin Song, LG Electronics, hyojin22.song@lge.com Editor: Soonbo Han, LG Electronics, soonbo.han@lge.com Abstract: This document proposes CSS extensions to support a round display. It extends existing CSS features including Media Queries[[MEDIAQ]], 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.
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:
Current user agents are not capable of detecting the shape of a display so that authors cannot apply a different layout for a round display. To resolve the issue, we propose to add the 'device-radius' media feature to Media Queries. The feature informs the web page of the property regarding the shape of the display.
To apply the shape of a display to content area, we propose to extend the 'shape-inside' property of CSS Shapes. We also propose to add the 'border-boundary' property to CSS Borders and introduce polar positioning for a better web design suitable for a round display.
Media Queries [[!MEDIAQ]] define mechanisms to support media-dependent style sheets, tailored for different media types. 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.
<link media="screen and (max-device-radius: 49%)" rel="stylesheet" href="rectangle.css" /> <link media="screen and (min-device-radius: 50%)" rel="stylesheet" href="round.css" />
This media feature accepts optional 'min-' or 'max-' prefixes to express 'greater or equal to' and 'smaller or equal to' contstriants. By the mechanism of media queries, if the value of the 'device-radius' media feature is less than or equal to 49%, 'rectangle-clock.css' is applied. If it is 50%, 'round-clock.css' is applied.
As in the 'border-radius' property, the 'device-radius' media feature can describe various round shapes of displays, such as rectangle, regular circle, ellipse, and rectangle with round corners.
Name: device-radius
Type: range
For: @media
Value: [ <> | <> ]
Initial: 0
Percentage: Refer to corresponding dimension of the display
The example below shows how a web page looks in the different shape of displays.
<!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
Devices where the 'device-radius' media feature is not applicable
<!-- index.html -->
<head>
<link media="screen and (max-device-radius: 49%)" rel="stylesheet" href="rectangle.css" />
<link media="screen and (min-device-radius: 50%)" rel="stylesheet" href="round.css" />
</head>
If this example code is loaded in a regular round display, 'round.css' will be applied by the media queries mechanism. To render the clock properly, 'round.css' could be written as follows.
#clockLayer {
border-radius: 50%;
}
#clockInset {
border-radius: 50%;
}
#date {
text-align: center;
}
...
(A) Rectangle Display
(w/ device-radius: 0%)
(B) Round Display
(w/ device-radius: 50%)
Devices where the 'device-radius' media feature is applicable
If the shapes of displays are various, such as polygons, we need to extend the media features more 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.
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'?
CSS Shapes [[CSS-SHAPES]] define the 'shape-inside' property that aligns contents along a possibly non-rectangular wrapping area. Web authors may use this feature to fit contents inside a round display. However, it could sometimes be hard to specify the wrapping area identical to the shape of a display. Thus, we propose to add a new value 'display' to the 'shape-inside' property to facilitate it. When the 'shape-inside' property on an element is set to 'display', its content (or contained element) is aligned along the display border automatically.
spec:css21; type:type; text:
Name: shape-inside
Applies to: block-level elements
Value: auto | outside-shape | [ <> || shape-box ] | <> | display
Initial: auto
Inherited: no
Media: visual
Computed value: computed lengths for <>, the absolute URI for <>, otherwise as specified
Animatable: as specified for <>, otherwise no
The example below shows how the 'shape-inside' property works when it is set to 'display'.
<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'
Align the content along the display border
Align a part of the content along the display border
What if content overflows? Clipping or scrolling?
We propose the 'border-boundary' property to set a boundary constraint that affects the borders of an element.
Name: border-boundary
Applies to: all elements
Value: none | parent | display
Initial: none
Inherited: no
Media: visual
When 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'
Align the content along the display border
Elements are often placed along a circle or concentric circles, and polar coordinates are 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 a fixed point within the containing element and an angle from a fixed direction. We propose to add 'polar' to the value of the 'position' property to support the polar coordinates of the children of an element. The 'polar-angle' and 'polar-distance' properties specify the position of an element (or a child).
polar', its children use the polar coordinates.
Name: position
Applies to: all elements
Value: static | relative | absolute | fixed | inherit | polar
Initial: static
Inherited: no
Media: visual
Name: polar-angle
For: @media
Applies to: all elements (parents should have 'position: polar' property)
Value: [ <> | <> ]?
Initial: 0
Media: visual
Inherited: no
Percentages: relative to radius of circle
Name: polar-distance
For: @media
Applies to: all elements (parents should have 'position: polar' property)
Value: [ <> | <> ]?
Initial: 0
Media: visual
Inherited: no
Percentages: relative to radius of circle
<body style="position: polar;">
<div id="circle1" style="polar-angle: 0deg; polar-distance: 20%"></div>
<div id="circle2" style="polar-angle: 90deg; polar-distance: 50%"></div>
<div id="circle3" style="polar-angle: 225deg; polar-distance: 100%"></div>
</body>
An example of polar positioning
By default, the 'polar-distance' property specifies the distance from the origin (or the center) of the containing element to that of the contained element. The 'polar-angle' property specifies the angle from the X-axis to the center of the contained element.
What value does the percentage value of the 'polar-distance' property refer to? The width of the containing element, or what? One feasible solution is to use the distance between the origin and the point on the border at the angle given by the 'polar-angle' property from the X-axis.
Will an element (or a child) itself be rotated through the 'polar-angle' property?