CÔNG TY TNHH ĐẦU TƯ THƯƠNG MẠI VÀ DỊCH VỤ HỮU QUYẾT
Số 2, ngách 1/1 Phố Thiên Hiền, Phường Mỹ Đình 1, Quận Nam Từ Liêm, Thành phố Hà Nội.
MST: 0110557925
CSS Shapes control the geometric shapes used for wrapping inline flow content outside an element. For Level 1, CSS Shapes can be applied to floats. A circle shape on a float will cause inline content to wrap around the circle shape instead of the float's bounding box.
Future levels of CSS Shapes will allow use of shapes on elements other than floats
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
The (archived) public mailing list [email protected] (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-shapes” in the subject, preferably like this: “[css-shapes] …summary of comment…”
This document was produced by the CSS Working Group (part of the Style Activity).
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This section is not normative.
This specification defines properties to control the geometry of an element's float area.
Float area
The area used for wrapping content around a float element. By default, the float area is the float element's margin box. This specification's ‘shape-outside
’ property can be used to define arbitrary, non-rectangular float areas.
Shapes define arbitrary geometric contours around which inline content flows. The shape-outside property defines the float area for a float.
If a user agent implements both CSS Shapes and CSS Exclusions, the shape-outside property defines the exclusion area for an exclusion.
A future level of CSS Shapes will define a shape-inside property, which will define a shape to wrap content within the element.
While the boundaries used for wrapping inline flow content outside an float can be defined using shapes, the actual box model does not change. If the element has specified margins, borders or paddings they will be computed and rendered according to the [CSS3BOX] module.
Float positioning is an exception. If a float has an outside shape, its positioning is resolved as defined in [CSS21] but the outside shape's bounding box is used in lieu of the float's margin box.
In the following example the left and right floating div
elements specify a triangular shape using the ‘shape-outside
’ property.
<div style="text-align:center;"> <div id="float-left"></div> <div id="float-right"></div> <div> Sometimes a web page's text content appears to be funneling your attention towards a spot on the page to drive you to follow a particular link. Sometimes you don't notice. </div> </div> <style type="text/css"> #float-left { shape-outside: polygon(0,0 100%,100% 0,100%); float: left; width: 40%; height: 12ex; } #float-right { shape-outside: polygon(100%,0 100%,100% 0,100%); float: right; width: 40%; height: 12ex; } </style> </div>
Shapes can be specified using syntax similar to SVG's basic shapes. The definitions use <length>
type and the <percentage>
types (see [CSS3VAL]). Percentages are resolved from the computed value of the ‘box-sizing
’ property [CSS3UI] on the element to which the property applies. For the radius r
of the circle
shape, a percentage value is resolved as specified in the SVG recommendation (see [SVG11]). Path styling like stroking is not considered part of the specified shape.
The following basic shapes are supported.
curve
’ values represent rx and ry. For rounded rectangles they define the x-axis radius and y-axis radius of the ellipse used to round off the corners of the rectangle. Negative values for rx and ry are invalid. See notes below on edge cases for these values. curve
’ values represent rx and ry. For rounded inset rectangles they define the x-axis radius and y-axis radius of the ellipse used to round off the corners of the inset rectangle. Negative values for rx and ry are invalid. See notes below on edge cases for these values. The UA will close a polygon by connecting the last vertex with the first vertex of the list.
The values for corner radii on rectangle or inset-rectangle are determined implicitly if either the rx or ry values are not specified, or are specified but with invalid values. If neither rx nor ry are properly specified, the values are 0 for both. If only one value is properly specified, that value is used for both. And if the values cause any of the curves to overlap, the solution for overlapping curves from CSS Backgrounds and Borders [CSS3BG] is used to avoid the overlap.
For interpolating between one basic shape and a second, the rules described below are applied.
Address security concern with automatic shape extractions for images
Another way of defining shapes is by specifying a source image whose alpha channel is used to compute the shape. The shape is computed to be the path that encloses the area where the opacity of the specified image is greater than the ‘shape-image-threshold
’ value. If the ‘shape-image-threshold
’ is not specified, the initial value to be considered is 0.5.
For animated raster image formats (such as GIF), the first frame of the animation sequence is used.
An image is floating to the left of a paragraph. The image shows the 3D version of the CSS logo over a transparent background. The logo has a shadow using an alpha-channel.
The image defines its float area through the ‘shape-outside
’ property and specifies a value of 35 pixels for the ‘shape-margin
’ property.
<p> <img id="CSSlogo" src="CSS-logo1s.png"/> blah blah blah blah... </p> <style> #CSSlogo { float: left; shape-outside: url("CSS-logo1s.png"); shape-image-threshold: 0.1; shape-margin: 35px; } </style>
The image needs two references to the image because this example uses the same image
It is perfectly possible to display an image and use a different image for its float area.
In the figure below, the alpha-channel threshold is represented by the dotted line around the CSS logo and the 35px shape-margin is visible between that line and the edges of each individual line of the paragraph.
It's then possible to affect where the lines of the paragraph start in three ways:
shape-margin
’ property shape-image-threshold
’ property A float shape around an image using its alpha-channel with a 35 pixels shape-margin
Shapes are declared with the ‘shape-outside
’ property, with possible modifications from the ‘shape-margin
’ property. The shape defined by the ‘shape-outside
’ and ‘shape-margin
’ properties changes the geometry of a float element's float area.
shape-outside
’ PropertyName: | shape-outside |
---|---|
Value: | auto | <basic-shape> | <uri> |
Initial: | auto |
Applies to: | floats |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | computed lengths for <basic-shape>, the absolute URI for <uri>, otherwise as specified |
The values of this property have the following meanings:
rectangle
’, ‘inset-rectangle
’, ‘circle
’, ‘ellipse
’ or ‘polygon
’. auto
’ had been specified. shape-image-threshold
’ Property The ‘shape-image-threshold
’ defines the alpha channel threshold used to extract the shape using an image. A value of 0.5 means that all the pixels that are more than 50% transparent define the path of the shape.
Name: | shape-image-threshold |
---|---|
Value: | <alphavalue> |
Initial: | 0.5 |
Applies to: | floats |
Inherited: | no |
Percentages: | alpha channel of the image specified by <uri> |
Media: | visual |
Computed value: | The same as the specified value after clipping the <alphavalue> to the range [0.0,1.0]. |
The values of this property have the following meanings:
shape-margin
’ property The ‘shape-margin
’ property adds a margin to a shape-outside. This defines a new shape where every point is the specified distance from the shape-outside. This property takes on positive values only.
Name: | shape-margin |
---|---|
Value: | <length> |
Initial: | 0 |
Applies to: | floats |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | the absolute length |
A ‘shape-margin
’ creating an offset from a circlular shape-outside. The blue rectangles represent inline content affected by the shape created by the margin.
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example"
, like this:
This is an example of an informative example.
Informative notes begin with the word “Note” and are set apart from the normative text with class="note"
, like this:
Note, this is an informative note.
Conformance to this specification is defined for three conformance classes:
A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.
A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)
An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.
So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.
To avoid clashes with future CSS features, the CSS 2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.
Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.
Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.
To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.
Further information on submitting testcases and implementation reports can be found from on the CSS Working Group's website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the [email protected] mailing list.
This specification is made possible by input from Andrei Bucur, Alexandru Chiculita, Arron Eicholz, Daniel Glazman, Arno Gourdol, Zoltan Horvath, Chris Jones, Bem Jones-Bey, Marcus Mielke, Alex Mogilevsky, Hans Muller, Mihnea Ovidenie, Virgil Palanciuc, Dirk Schulze, Peter Sorotokin, Bear Travis, Eugene Veselov, Stephen Zilles and the CSS Working Group members.
Property | Values | Initial | Applies to | Inh. | Percentages | Media |
---|---|---|---|---|---|---|
shape-image-threshold | <alphavalue> | 0.5 | floats | no | alpha channel of the image specified by <uri> | visual |
shape-margin | <length> | 0 | floats | no | N/A | visual |
shape-outside | auto | <basic-shape> | <uri> | auto | floats | no | N/A | visual |