Working with CSS3 3D Transform Functions

CSSWeb DevelopmentFront End Technology

Using with 3d transforms, we can move element to x-axis, y-axis and z-axis. Following are some of the methods of CSS3 3D Transform −

Below methods are used to call 3D transforms −

Sr.No.Value & Description
1matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
Used to transforms the element by using 16 values of matrix
2translate3d(x,y,z)
Used to transforms the element by using x-axis,y-axis and z-axis
3translateX(x)
Used to transforms the element by using x-axis
4translateY(y)
Used to transforms the element by using y-axis
5translateZ(z)
Used to transforms the element by using y-axis

Following is the code for CSS3 3D transform functions −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.container {
   display: inline-block;
   width: 200px;
   height: 200px;
   border: 1px solid #CCC;
   margin-left: 20px;
}
.rotateX {
   width: 100%;
   height: 100%;
   background: rgb(52, 0, 241);
   transform: perspective(600px) rotateX(85deg);
}
.rotateY {
   width: 100%;
   height: 100%;
   background: rgb(55, 0, 255);
   transform: perspective(600px) rotateY(75deg);
}
.translateZ{
   width: 100%;
   height: 100%;
   background: rgb(55, 0, 255);
   transform: perspective(600px) translateZ(-200px);
}
</style>
</head>
<body>
<h1>3D transform function example</h1>
<div class="container">
<div class="rotateX"></div>
</div>
<div class="container">
<div class="rotateY"></div>
</div>
<div class="container">
<div class="translateZ"></div>
</div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 11-May-2020 13:48:19
Advertisements