object.style.transform = "value"; <'transform'> = none | <transform-list> <transform-list> = <transform-function>+ <transform-function> = <matrix()> | <translate()> | <translateX()> | <translateY()> | <scale()> | <scaleX()> | <scaleY()> | <rotate()> | <skew()> | <skewX()> | <skewY()> | <matrix3d()> | <translate3d()> | <translateZ()> | <scale3d()> | <scaleZ()> | <rotate3d()> | <rotateX()> | <rotateY()> | <rotateZ()> | <perspective()> <matrix()> = matrix( <number>#{6} ) Specifies a 2D transformation in the form of a transformation matrix of the six values a, b, c, d, e, f.
<translate()> = translate( <length-percentage> , <length-percentage>? ) Specifies a 2D translation by the vector [tx, ty], where tx is the first translation-value parameter and ty is the optional second translation-value parameter.
<translateX()> = translateX( <length-percentage> ) Specifies a translation by the given amount in the X direction.
<translateY()> = translateY( <length-percentage> ) Specifies a translation by the given amount in the Y direction.
<scale()> = scale( <number> , <number>? ) Specifies a 2D scale operation by the [sx,sy] scaling vector described by the 2 parameters.
<scaleX()> = scaleX( <number> ) Specifies a 2D scale operation using the [sx,1] scaling vector, where sx is given as the parameter.
<scaleY()> = scaleY( <number> ) Specifies a 2D scale operation using the [1,sy] scaling vector, where sy is given as the parameter.
<rotate()> = rotate( [ <angle> | <zero> ] ) Specifies a 2D rotation by the angle specified in the parameter about the origin of the element, as defined by the transform-origin property.
<skew()> = skew( [ <angle> | <zero> ] , [ <angle> | <zero> ]? ) Specifies a 2D skew by [ax,ay] for X and Y. Exists for compatibility reasons and should not be used in new content. Use skewX() or skewY() instead, noting that the behavior of skew() is different from multiplying skewX() with skewY().
<skewX()> = skewX( [ <angle> | <zero> ] ) Specifies a 2D skew transformation along the X axis by the given angle.
<skewY()> = skewY( [ <angle> | <zero> ] ) Specifies a 2D skew transformation along the Y axis by the given angle.
<matrix3d()> = matrix3d( <number>#{16} ) Specifies a 3D transformation as a 4x4 homogeneous matrix of 16 values in column-major order.
<translate3d()> = translate3d( <length-percentage> , <length-percentage> , <length> ) Specifies a 3D translation by the vector [tx,ty,tz], with tx, ty and tz being the first, second and third translation-value parameters respectively.
<translateZ()> = translateZ( <length> ) Specifies a 3D translation by the vector [0,0,tz] with the given amount in the Z direction.
<scale3d()> = scale3d( <number> , <number>, <number> ) Specifies a 3D scale operation by the [sx,sy,sz] scaling vector described by the 3 parameters.
<scaleZ()> = scaleZ( <number> ) Specifies a 3D scale operation using the [1,1,sz] scaling vector, where sz is given as the parameter.
<rotate3d()> = rotate3d( <number> , <number> , <number> , [ <angle> | <zero> ] ) Specifies a 3D rotation by the angle specified in last parameter about the [x,y,z] direction vector described by the first three parameters.
<rotateX()> = rotateX( [ <angle> | <zero> ] ) Same as rotate3d(1, 0, 0, <angle>).
<rotateY()> = rotateY( [ <angle> | <zero> ] ) Same as rotate3d(0, 1, 0, <angle>).
<rotateZ()> = rotateZ( [ <angle> | <zero> ] ) Same as rotate3d(0, 0, 1, <angle>), which is a 3d transform equivalent to the 2d transform rotate(<angle>).
<perspective()> = perspective( <length [0,∞]> ) Specifies a perspective projection matrix. This matrix scales points in X and Y based on their Z value, scaling points with positive Z values away from the origin, and those with negative Z values towards the origin. Points on the z=0 plane are unchanged. The parameter represents the distance of the z=0 plane from the viewer. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect.
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>matrix3d</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: perspective(100px);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>perspective</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: rotate(180deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>rotate</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: rotate3d(1, 1, 1, 45deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>rotate3d</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: rotateX(45deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>rotateX</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: rotateY(45deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>rotateY</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: rotateZ(45deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>rotateZ</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: scale(2, 2);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>scale</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: scale3d(2, 2, 2);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>scale3d</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: scaleX(2);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>scaleX</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: scaleY(2);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>scaleY</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: scaleZ(2);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>scaleZ</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: skew(15deg, 15deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>skew</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: skewX(45deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>skewX</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: skewY(45deg);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>skewY</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: translate(100px, 100px);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>translate</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: translate3d(100px, 100px, 50px);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>translate3d</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: translateX(100px);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>translateX</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: translateY(100px);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>translateY</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
transform: translateZ(50px);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<p>translateZ</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<button onmouseover="myfunction(innerHTML)">initial</button><br>
<button onmouseover="myfunction(value)" value="matrix(1, 0, 0, 1, 0, 0)">matrix</button>
<button onmouseover="myfunction(value)" value="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)">matrix3d</button><br>
<button onmouseover="myfunction(value)" value="perspective(100px)">perspective</button><br>
<button onmouseover="myfunction(value)" value="rotate(180deg)">rotate</button>
<button onmouseover="myfunction(value)" value="rotate3d(1, 1, 1, 45deg)">rotate3d</button>
<button onmouseover="myfunction(value)" value="rotateX(45deg)">rotateX</button>
<button onmouseover="myfunction(value)" value="rotateY(45deg)">rotateY</button>
<button onmouseover="myfunction(value)" value="rotateZ(45deg)">rotateZ</button><br>
<button onmouseover="myfunction(value)" value="scale(2, 2)">scale</button>
<button onmouseover="myfunction(value)" value="scale3d(2, 2, 2)">scale3d</button>
<button onmouseover="myfunction(value)" value="scaleX(2)">scaleX</button>
<button onmouseover="myfunction(value)" value="scaleY(2)">scaleY</button>
<button onmouseover="myfunction(value)" value="scaleZ(2)">scaleZ</button><br>
<button onmouseover="myfunction(value)" value="skew(15deg, 15deg)">skew</button>
<button onmouseover="myfunction(value)" value="skewX(45deg)">skewX</button>
<button onmouseover="myfunction(value)" value="skewY(45deg)">skewY</button><br>
<button onmouseover="myfunction(value)" value="translate(100px, 100px)">translate</button>
<button onmouseover="myfunction(value)" value="translate3d(100px, 100px, 50px)">translate3d</button>
<button onmouseover="myfunction(value)" value="translateX(100px)">translateX</button>
<button onmouseover="myfunction(value)" value="translateY(100px)">translateY</button>
<button onmouseover="myfunction(value)" value="translateZ(50px)">translateZ</button>
<p>transform</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
<script>
function myfunction(myparameter)
{
document.querySelector(".front").style.transform = myparameter;
}
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.face
{
color: white;
font-family: sans-serif;
font-size: 25px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.left
{
background-color: rgba(255, 0, 0, 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.right
{
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.bottom
{
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.top
{
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.front
{
background-color: rgba(0, 0, 255, 0.5);
}
.back
{
background-color: rgba(255, 0, 255, 0.5);
transform: rotateY(180deg) translateZ(50px);
}
</style>
</head>
<body>
<button>initial</button><br>
<button value="matrix(1, 0, 0, 1, 0, 0)">matrix</button>
<button value="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)">matrix3d</button><br>
<button value="perspective(100px)">perspective</button><br>
<button value="rotate(180deg)">rotate</button>
<button value="rotate3d(1, 1, 1, 45deg)">rotate3d</button>
<button value="rotateX(45deg)">rotateX</button>
<button value="rotateY(45deg)">rotateY</button>
<button value="rotateZ(45deg)">rotateZ</button><br>
<button value="scale(2, 2)">scale</button>
<button value="scale3d(2, 2, 2)">scale3d</button>
<button value="scaleX(2)">scaleX</button>
<button value="scaleY(2)">scaleY</button>
<button value="scaleZ(2)">scaleZ</button><br>
<button value="skew(15deg, 15deg)">skew</button>
<button value="skewX(45deg)">skewX</button>
<button value="skewY(45deg)">skewY</button><br>
<button value="translate(100px, 100px)">translate</button>
<button value="translate3d(100px, 100px, 50px)">translate3d</button>
<button value="translateX(100px)">translateX</button>
<button value="translateY(100px)">translateY</button>
<button value="translateZ(50px)">translateZ</button>
<p>transform</p>
<div class="cube">
<div class="face left">left</div>
<div class="face right">right</div>
<div class="face bottom">bottom</div>
<div class="face top">top</div>
<div class="face front">front</div>
<div class="face back">back</div>
</div>
<script>
function myfunction(myparameter)
{
document.querySelector(".front").style.transform = myparameter;
}
const myelements = document.querySelectorAll("button");
for(let myelement of myelements)
{
let myargument = myelement.innerHTML;
if(myelement.value)
{
myargument = myelement.value;
}
myelement.addEventListener("mouseover", function(){myfunction(myargument)});
}
</script>
</body>
</html>