2D CSS transforms allow you to move, rotate, scale, and skew an element on two planes.
The following 2D transformation methods can be used with the transform property:
- matrix()
- rotate()
- scaleX()
- scaleY()
- scale()
- skewX()
- skewY()
- skew()
- translate()
/* scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() */
div {
transform: matrix(1, -0.5, 0, 1, 0, 0);
}
/* rotates the element clockwise with 20 degrees */
div {
transform: rotate(20deg);
}
/* increases the element to be 2X its orignal width */
div {
transform: scaleX(2);
}
/* increases the element to be 2X its original height */
div {
transform: scaleY(2);
}
/* increases the element to be 2X its orignal width and 3X its original height */
div {
transform: scale(2, 3);
}
/* skews the element 20 degrees along the X-axis */
div {
transform: skewX(20deg);
}
/* skews the element 20 degrees along the Y-axis */
div {
transform: skewY(20deg);
}
/* skews the element 20 degrees on the X-axis, and 10 degrees on the Y-axis */
div {
transform: skew(20deg, 10deg);
}
/* moves the element 50px to the right and 25px down from its current position */
div {
transform: translate(25px, 50px);
}
Properties
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
CSS Books
All are affiliate links. Thank you for your support!
CSS NOTES:
- The “inherit”, “initial” and “unset” keywords can be used with any CSS property to set its value
- In CSS there are many ways to express a color value in a property
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.