HTML CSS examples for CSS Property:transform-origin
The transform-origin CSS property sets the origin of transformation for an element.
The following table summarizes the transform-origin Property.
Item | Value |
---|---|
Default value: | 50% 50% 0 |
Applies to: | Transformable elements |
Inherited: | No |
Animatable: | Yes. |
The syntax of the property is as follows:
transform-origin: x-position | y-position | z-position | initial | inherit
The following table describes the values of this property.
Value | Description |
---|---|
x-position | Represents the horizontal position (or offset) of the transform origin. |
y-position | Represents the vertical position (or offset) of the transform origin. |
z-position | A length value describing how far from the user eye the origin is set for 3D transforms. Percentage values are invalid. |
initial | Sets this property to its default value. |
inherit | take the value of its parent element transform-origin property. |
x-position can have one of the following values:
y-position can have one of the following values:
The example below shows the transform-origin property.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of CSS3 transform-origin Property</title> <style type="text/css"> img {<!-- w w w.j a va 2s . co m--> /* Chrome, Safari, Opera */ -webkit-transform: rotate(30deg); -webkit-transform-origin: 25% bottom; /* Firefox */ -moz-transform: rotate(30deg); -moz-transform-origin: 25% bottom; /* IE 9 */ -ms-transform: rotate(30deg); -ms-transform-origin: 25% bottom; /* Standard syntax */ transform: rotate(30deg); transform-origin: 25% bottom; } .box{ margin: 50px; width:120px; height:110px; background: url("../images/star-fish-transparent.png") no-repeat; } </style> </head> <body> <div class="box"> <img src="../images/star-fish.png" alt="Star Fish"> </div> </body> </html>