Safari Reference Library Apple Developer
Search

CSS Property Functions

This chapter describes the functions you can use with supported CSS properties.

Image Functions

color-stop

Specifies an intermediary color value for a gradient.

color-stop(stop, color)
Parameters
stop

The point in the gradient that should have the specified color value. Represented as a percentage or a decimal value between 0 and 1.

color

The color of the gradient at the stop.

Discussion

For more information, see “-webkit-gradient.”

Availability

Available in Safari 4.0 and later.

from

A convenience function for the “color-stop” function that specifies the first color stop in a gradient.

from(color)
Parameters
color

The color of the gradient at the stop.

Discussion

Equivalent to calling color-stop() with a stop value of 0%.

Availability

Available in Safari 4.0 and later.

to

A convenience function for the “color-stop” function that specifies the last color stop in a gradient.

to(color)
Parameters
color

The color of the gradient at the stop.

Discussion

Equivalent to calling color-stop() with a stop value of 100%.

Availability

Available in Safari 4.0 and later.

-webkit-canvas

Specifies a canvas for drawing programmatically with Javascript.

-webkit-canvas(canvas)
Parameters
canvas

The name of the canvas.

Discussion

The -webkit-canvas() function can be used in any place an image URL is used.

Canvases specified with the -webkit-canvas() function can be accessed in Javascript with the method getCSSCanvasContext(), which returns a CanvasRenderingContext object. The identifier passed to getCSSCanvasContext() should be the same as the value for canvas.

Specifying a new width or height for the canvas in subsequent calls to getCSSCanvasContext() clears the canvas buffer.

Availability

Available in Safari 4.0 and later.

-webkit-gradient

Generates a gradient image.

-webkit-gradient(type, start_point, end_point, / stop...)
-webkit-gradient(type, inner_center, inner_radius, outer_center, outer_radius, / stop...)
Parameters
type

The type of gradient. Can be linear or radial.

start_point

The point in the image at which the linear gradient begins.

end_point

The point in the image at which the linear gradient ends.

stop

A color-stop() function indicating the desired color for the gradient at a particular point in its progression.

inner_center

The center point of the inner, starting circle in a radial gradient.

inner_radius

The radius of the inner, starting circle in a radial gradient.

outer_center

The center point of the outer, ending circle in a radial gradient.

outer_radius

The radius of the outer, ending circle in a radial gradient.

Constants
left top

The point corresponding to the top left corner of the image.

left bottom

The point corresponding to the bottom left corner of the image.

right top

The point corresponding to the top right corner of the image.

right bottom

The point corresponding to the bottom right corner of the image.

Discussion

-webkit-gradient() can be used in any place an image URL is used.

A linear gradient determines its color by interpolating between values specified by the color-stop() functions provided. Each color-stop() function specifies a percentage or a decimal between 0 and 1 and a color, indicating that the gradient should have the specified color value at the specified fraction of the gradient’s length. The shorthand functions from() and to() are supported as special-case color-stop() functions. The following example creates a linear gradient that shifts from yellow to orange in its first half and from orange to red in its second half, moving from the top left of the image to the bottom right of the image:

-webkit-gradient(linear, left top, right bottom, from(#ff0), color-stop(0.5, orange), to(rgb(255, 0, 0));

A radial gradient specifies its start and end with two (typically concentric) circles, each identified by a center point and radius. The color value at a point between the circumference of the inner circle and the circumference of the outer circle is determined by interpolating between color-stop() functions. The color value inside the inner circle is the color value of the first color-stop() function.

Availability

Available in Safari 4.0 and later.

Visual Effects Timing Functions

cubic-bezier

Specifies a cubic Bézier curve.

cubic-bezier(P1x,P1y,P2x,P2y)

Parameters
P1x, P1y

First point in the Bézier curve.

P2x, P2y

Second point in the Bézier curve.

Discussion

A cubic Bézier curve is defined by four control points, P0 through P3. P0 and P3 are always set to (0,0) and (1,1). This function is used to set the values for the points in between, points P1 and P2. Each point is specified by both an x and y value.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

Visual Effects Transform Functions

matrix

Specifies a 2D transformation in the form of a transformation matrix of six values.

matrix(m11, m12, m21, m22, tX, tY)

Parameters
m11, m12, m21, m22

Elements of a 2 x 2 matrix in column-major order.

1,1

2,1

1,2

2,2

tX, tY

The x and y translation elements.

Discussion

Passing matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f].

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

matrix3d

Specifies a 3D transformation as a 4 x 4 matrix.

matrix3d(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m31, m33)

Parameters
m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m31, m33

Defines a 4 x 4 homogeneous matrix of 16 values in column-major order (0,0; 0,1; 0,2; ...).

0,0

1,0

2,0

3,0

0,1

1,1

2,1

3,1

0,2

1,2

2,2

3,2

0,3

1,3

2,3

3,3

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

perspective

Specifies a perspective projection matrix.

perspective(depth)

Parameters
depth

The distance, in pixels, of the z=0 plane from the viewer.

Discussion

This matrix maps a viewing cube onto a pyramid whose base is infinitely far away from the viewer and whose peak represents the viewer's position.

The viewable area is the region bounded by the four edges of the viewport (the portion of the browser window used for rendering the webpage between the viewer’s position and a point at a distance of infinity from the viewer).

Lower values for this property give a more flattened pyramid and therefore a more pronounced perspective effect. A value of 1000 pixels gives a moderate amount of foreshortening, and a value of 200 pixels gives an extreme amount.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

rotate

Specifies a 2D rotation around the origin of the element.

rotate(angle)

Parameters
angle

The rotation angle. The angle may be specified using deg, rad or grad units.

Discussion

The rotation operation corresponds to the matrix [cos(angle) sin(angle) -sin(angle) cos(angle) 0 0]. The origin of the element is specified using the -webkit-transform-origin property.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

rotate3d

Specifies a clockwise 3D rotation.

rotate3d(x, y, z, angle)

Parameters
x, y, z

The [x,y,z] direction vector for the rotation.

If the direction vector is not of unit length, it will be normalized. If the direction vector cannot be normalized, such as [0, 0, 0], the rotation will not be applied.

angle

The rotation angle. The angle may be specified using deg, rad or grad units.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

rotateX

Specifies a clockwise rotation by the given angle about the x-axis.

rotateX(angle)

Parameters
angle

The rotation angle. The angle may be specified using deg, rad or grad units.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

rotateY

Specifies a clockwise rotation by the given angle about the y-axis.

rotateY(angle)

Parameters
angle

The rotation angle. The angle may be specified using deg, rad or grad units.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

rotateZ

Specifies a clockwise rotation by the given angle about the z-axis.

rotateZ(angle)

Parameters
angle

The angle of the rotation. The angle may be specified using deg, rad or grad units.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

scale

Specifies a 2D scale operation.

scale(scaleX [, scaleY])

Parameters
scaleX

The scaling factor to apply in the x direction.

scaleY

The scaling factor to apply in the y direction. If not specified, defaults to scaleX.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

scale3d

Specifies a 3D scale operation.

scale3d(scaleX, scaleY, scaleZ)

Parameters
scaleX

The scaling factor to apply in the x direction.

scaleY

The scaling factor to apply in the y direction.

scaleZ

The scaling factor to apply in the z direction.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

scaleX

Scales in the x direction.

scaleX(sx)

Parameters
sx

The scaling factor to apply to the x direction.

Discussion

This function specifies a scale operation using the [sx, 1, 1] scaling vector.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

scaleY

Scales in the y direction.

scaleY(sy)

Parameters
sy

The scaling factor to apply to the y direction.

Discussion

This function specifies a scale operation using the [1,sy,1] scaling vector.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

scaleZ

Scales in the z direction.

scaleZ(sz)

Parameters
sz

The scaling factor to apply to the z direction.

Discussion

This function specifies a scale operation using the [1,1,sz] scaling vector.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

skew

Specifies a skew transformation along the x and y axes by given angles.

skew(angleX [, angleY])

Parameters
angleX

The angle of the skew along the x-axis. The angle may be specified using deg, rad or grad units.

angleY

The angle of the skew along the y-axis. The angle may be specified using deg, rad or grad units. If not specified, defaults to 0.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

skewX

Specifies a skew transformation along the x-axis by the given angle.

skewX(angle)

Parameters
angle

The angle of the skew. The angle may be specified using deg, rad or grad units.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

skewY

Specifies a skew transformation along the x-axis by the given angle.

skewY(angle)

Parameters
angle

The angle of the skew. The angle may be specified using deg, rad or grad units.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

translate

Specifies a 2D translation vector.

translate(deltaX [, deltaY])

Parameters
deltaX

The number of units to translate along the x-axis. This value may be a percentage or a length.

deltaY

The number of units to translate along the y-axis. If not specified, the y translation defaults to 0. This value may be a percentage or a length.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

translate3d

Specifies a 3D translation vector.

translate3d(deltaX, deltaY, deltaZ)

Parameters
deltaX

The number of units to translate along the x-axis. This value may be a percentage or a length.

deltaY

The number of units to translate along the y-axis. This value may be a percentage or a length.

deltaZ

The number of units to translate along the z-axis. This value may be a percentage or a length.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.

translateX

Specifies a translation in the x direction.

translateX(deltaX)

Parameters
deltaX

The number of units to translate along the x-axis. This value may be a percentage or a length.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

translateY

Specifies a translation in the y direction.

translateY(deltaY)

Parameters
deltaY

The number of units to translate along the y-axis. This value may be a percentage or a length.

Availability

Available in Safari 3.1 and later. Available in iPhone OS 2.0 and later.

translateZ

Specifies a translation in the z direction.

translateZ(deltaZ)

Parameters
deltaZ

The number of units to translate along the z-axis. This value may be a percentage or a length.

Availability

Available in Safari 4.0.3 and later running on Mac OS X v10.6 and later. Available in iPhone OS 2.0 and later.




Last updated: 2010-05-07

Did this document help you? Yes It's good, but... Not helpful...