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;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 50, 1);
}
</style>
</head>
<body>
<p>matrix3d</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: perspective(100px) translateZ(25px);
}
</style>
</head>
<body>
<p>perspective</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: rotate(45deg);
}
</style>
</head>
<body>
<p>rotate</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: rotate3d(1, 1, 1, 45deg);
}
</style>
</head>
<body>
<p>rotate3d</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: rotateX(45deg);
}
</style>
</head>
<body>
<p>rotateX</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: rotateY(45deg);
}
</style>
</head>
<body>
<p>rotateY</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: rotateZ(45deg);
}
</style>
</head>
<body>
<p>rotateZ</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: scale(1.5, 0.5);
}
</style>
</head>
<body>
<p>scale</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: scale3d(1.5, 0.5, 1);
}
</style>
</head>
<body>
<p>scale3d</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: scaleX(1.5);
}
</style>
</head>
<body>
<p>scaleX</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: scaleY(1.5);
}
</style>
</head>
<body>
<p>scaleY</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: scaleZ(1.5);
}
</style>
</head>
<body>
<p>scaleZ</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: skew(15deg, 15deg);
}
</style>
</head>
<body>
<p>skew</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: skewX(45deg);
}
</style>
</head>
<body>
<p>skewX</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: skewY(45deg);
}
</style>
</head>
<body>
<p>skewY</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: translate(100px, 100px);
}
</style>
</head>
<body>
<p>translate</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: translate3d(100px, 100px, 50px);
}
</style>
</head>
<body>
<p>translate3d</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: translateX(100px);
}
</style>
</head>
<body>
<p>translateX</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: translateY(100px);
}
</style>
</head>
<body>
<p>translateY</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
transform: translateZ(50px);
}
</style>
</head>
<body>
<p>translateZ</p>
<div class="cube">
<div class="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.cube
{
height: 100px;
margin: 100px;
perspective: 100px;
transform-style: preserve-3d;
width: 100px;
}
.side
{
color: white;
font-family: sans-serif;
font-size: 50px;
height: 100px;
line-height: 100px;
position: absolute;
text-align: center;
width: 100px;
}
.side1
{
background-color: rgb(255 0 0 / 0.5);
transform: rotateY(-90deg) translateZ(50px);
}
.side2
{
background-color: rgb(255 255 0 / 0.5);
transform: rotateY(90deg) translateZ(50px);
}
.side3
{
background-color: rgb(0 255 0 / 0.5);
transform: rotateX(90deg) translateZ(50px);
}
.side4
{
background-color: rgb(0 255 255 / 0.5);
transform: rotateX(-90deg) translateZ(50px);
}
.side5
{
background-color: rgb(0 0 255 / 0.5);
transform: rotateY(180deg) translateZ(50px);
}
.side6
{
background-color: rgb(255 0 255 / 0.5);
}
</style>
</head>
<body>
<button>initial</button><br>
<button value="matrix(1, 0, 0, 1, 100, 100)">matrix</button>
<button value="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 50, 1)">matrix3d</button><br>
<button value="perspective(100px) translateZ(25px)">perspective</button><br>
<button value="rotate(45deg)">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(1.5, 0.5)">scale</button>
<button value="scale3d(1.5, 0.5, 1)">scale3d</button>
<button value="scaleX(1.5)">scaleX</button>
<button value="scaleY(1.5)">scaleY</button>
<button value="scaleZ(1.5)">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="side side1">1</div>
<div class="side side2">2</div>
<div class="side side3">3</div>
<div class="side side4">4</div>
<div class="side side5">5</div>
<div class="side side6">6</div>
</div>
<script>
function myfunction(myparameter)
{
const mytarget = myparameter.target;
const myproperty = mytarget.value || mytarget.innerHTML;
document.querySelector(".side6").style.transform = myproperty;
}
for(const mybutton of document.querySelectorAll("button"))
{
mybutton.addEventListener("mouseover", myfunction);
}
</script>
</body>
</html>