首页 > 解决方案 > 如何将使用变换 css 属性转换为顺风 css?

问题描述

我正在尝试将此类转换为 css,其中一些东西很容易转换。

但是这3个道具我不确定是否有可能拥有它tailwind.css?

.toast-top-center {
  position: fixed;
  z-index: 99;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Trying to add with tailwind CSS

.toast-top-center {
  @apply fixed z-40;

  top: 10%; 
  left: 50%;
  transform: translate(-50%, -50%);
}
``

标签: htmlcsssasstailwind-css

解决方案


Your CSS class with Tailwind would be:

.toast-top-center {
  @apply fixed z-99 transform -translate-x-1/2 -translate-y-1/2 left-1/2 top-1/10;
}

For this to work you would either have to switch from Tailwind to WindiCSS, or change your tailwind.config.js like this:

module.exports = {
    theme: {
      inset: {
       // Other fractions if you need them elsewhere
       '1/2': 50%,
       '1/10': '10%',
      },
      zIndex: {
        // Other indexes if you need them elsewhere
        '99': 99
      }
    }
  }

推荐阅读