CSS Tutorials

Overview

2D CSS transforms allow you to move, rotate, scale, and skew an element on two planes.

Note

The following are basic examples. Towards the bottom of this page you’ll find a complete list of all applicable properties, where you can find more information on the properties discussed, and sometimes find more involved properties not discussed on this page.

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


CSS Notes:


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.