- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS Function - matrix3d()
The CSS function matrix3d() is similar to the matrix() function, but specifies a 3D transformation represented by a homogeneous 4x4 matrix, resulting in a data type of <transform-matrix>.
Possible values
a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 - These are <number>s describing the linear transformation.
a4 b4 c4 d4 - These are <number>s describing the translation to apply.
Syntax
The matrix3d() function is defined with 16 values described in column-major order.
matrix3d(a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4)
Each parameter (a1 through d4) corresponds to a specific value in the 4x4 matrix, representing a 3D transformation.
ai (where i is the row number and ranges from 1 to 4): Represents the elements in the ith row of the matrix.
bi (where i is the row number and ranges from 1 to 4): Represents the elements in the ith row of the matrix.
ci (where i is the row number and ranges from 1 to 4): Represents the elements in the ith row of the matrix.
di (where i is the row number and ranges from 1 to 4): Represents the elements in the ith row of the matrix.
CSS matrix3d() - Basic example
The following example demonstrates the usage of matrix3d() and also demonstrates a dynamic animation involving both translation and scaling effects
<html>
<head>
<style>
html {
width: 100%;
}
body {
height: 100vh;
display: flex;
flex-flow: row wrap;
justify-content: center;
align-content: center;
}
.box {
width: 150px;
height: 150px;
background: #FFAC1C;
border-radius: 20px;
text-align: center;
line-height: 150px;
color: white;
font-family: Arial, sans-serif;
font-size: 18px;
animation: RotateScale 2s alternate linear infinite;
}
@keyframes RotateScale {
from {
transform: matrix3d(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
}
to {
transform: matrix3d(
1.2, 0, 0, 0,
0, 1.2, 0, 0,
0, 0, 1.2, 0,
0, 0, 0, 1
);
}
}
</style>
</head>
<body>
<div class="box">
matrix3d() example
</div>
</body>
</html>
CSS matrix3d() - 3d Cube
The example demonstrates a 3d cube made from DOM elements and transformations. It can be interactively transformed using matrix3d() when hovered or focused.
<html>
<head>
<style>
#custom-cube {
width: 150px;
height: 150px;
transform-style: preserve-3d;
transition: transform 1s;
transform: rotate3d(1, 1, 1, 45deg);
margin: 50px auto;
}
#custom-cube:hover,
#custom-cube:focus {
transform: rotate3d(1, 1, 1, 45deg) matrix3d(
1,
0,
0,
0,
0,
1,
6,
0,
0,
0,
1,
0,
50,
100,
0,
1.2
);
}
.face {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: absolute;
backface-visibility: inherit;
font-size: 40px;
color: #fff;
}
.front {
background: rgba(255, 99, 71, 0.9);
transform: translateZ(75px);
}
.back {
background: rgba(0, 128, 0, 0.9);
transform: rotateY(180deg) translateZ(75px);
}
.right {
background: rgba(255, 165, 0, 0.9);
transform: rotateY(90deg) translateZ(75px);
}
.left {
background: rgba(0, 0, 255, 0.9);
transform: rotateY(-90deg) translateZ(75px);
}
.top {
background: rgba(218, 112, 214, 0.9);
transform: rotateX(90deg) translateZ(75px);
}
.bottom {
background: rgba(255, 0, 255, 0.9);
transform: rotateX(-90deg) translateZ(75px);
}
</style>
</head>
<body>
<section id="custom-cube" tabindex="0">
<div class="face front"> Face A</div>
<div class="face back">Face B</div>
<div class="face right">Face C</div>
<div class="face left">Face D</div>
<div class="face top">Face E</div>
<div class="face bottom">Face F</div>
</section>
</body>
</html>