Skew

Tailwind CSS version

v1.2.0+

Utilities for skewing elements with transform.

Class reference

Class
Properties
.skew-x-0—transform-skew-x: 0;
.skew-x-1—transform-skew-x: 1deg;
.skew-x-2—transform-skew-x: 2deg;
.skew-x-3—transform-skew-x: 3deg;
.skew-x-6—transform-skew-x: 6deg;
.skew-x-12—transform-skew-x: 12deg;
.-skew-x-12—transform-skew-x: -12deg;
.-skew-x-6—transform-skew-x: -6deg;
.-skew-x-3—transform-skew-x: -3deg;
.-skew-x-2—transform-skew-x: -2deg;
.-skew-x-1—transform-skew-x: -1deg;
.skew-y-0—transform-skew-y: 0;
.skew-y-1—transform-skew-y: 1deg;
.skew-y-2—transform-skew-y: 2deg;
.skew-y-3—transform-skew-y: 3deg;
.skew-y-6—transform-skew-y: 6deg;
.skew-y-12—transform-skew-y: 12deg;
.-skew-y-12—transform-skew-y: -12deg;
.-skew-y-6—transform-skew-y: -6deg;
.-skew-y-3—transform-skew-y: -3deg;
.-skew-y-2—transform-skew-y: -2deg;
.-skew-y-1—transform-skew-y: -1deg;

Usage

Skew an element by first enabling transforms with the transform utility, then specifying the skew angle using the skew-x-{amount} and skew-y-{amount} utilities.

Skew - 图1

  1. <img class="transform skew-y-0 ...">
  2. <img class="transform skew-y-3 ...">
  3. <img class="transform skew-y-6 ...">
  4. <img class="transform skew-y-12 ...">

Note that because Tailwind implements transforms using CSS custom properties, the transform utilities are not supported in older browsers like IE11. If you need transforms for your project and need to support older browsers, add your own utilities or other custom CSS.

Responsive

To control the skew of an element at a specific breakpoint, add a {screen}: prefix to any existing skew utility. For example, use md:skew-6 to apply the skew-6 utility at only medium screen sizes and above.

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Skew - 图2

all

Skew - 图3

sm

Skew - 图4

md

Skew - 图5

lg

Skew - 图6

xl

  1. <img class="transform skew-y-0 sm:skew-y-12 md:-skew-y-12 lg:skew-x-6 xl:-skew-x-6...">

Skew - 图7

Customizing

Skew scale

By default Tailwind provides seven general purpose skew utilities. You change, add, or remove these by customizing the skew section of your Tailwind theme config.

  1. // tailwind.config.js
  2. module.exports = {
  3. theme: {
  4. extend: {
  5. skew: {
  6. + '25': '25deg',
  7. + '60': '60deg',
  8. }
  9. }
  10. }
  11. }

Learn more about customizing the default theme in the theme customization documentation.

Responsive and pseudo-class variants

By default, only responsive, hover and focus variants are generated for skew utilities.

You can control which variants are generated for the skew utilities by modifying the skew property in the variants section of your tailwind.config.js file.

For example, this config will also generate active and group-hover variants:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. // ...
  5. - skew: ['responsive', 'hover', 'focus'],
  6. + skew: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
  7. }
  8. }

Disabling

If you don’t plan to use the skew utilities in your project, you can disable them entirely by setting the skew property to false in the corePlugins section of your config file:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + skew: false,
  6. }
  7. }

← Translate   Transform Origin →