为什么当我在Tailwind.css中扩展主题时,应用程序的布局会中断?

oknwwptz  于 2022-12-01  发布在  其他
关注(0)|答案(1)|浏览(183)

我想为我的网站创建一个动画。我使用tailwind.css的样式。

module.exports = {
  content: ["./index.html", "./src/**/*.{js,jsx}"],
  theme: {
    colors: {
      primary: "#E51114",
      secondary: "#434242",
      lightGray: "#CCCCCC",
      dimmedWhite: "#F5F5F5",
      white: "#FFFFFF",
    },
    extend: {
      keyframes: {
        slideInOut: {
          "0%": { transform: "translateX(calc(100% + 30px)" },
          "10%": { transform: "translateX(0)" },
          "90%": { transform: "translateX(0)" },
          "100%": { transform: "translateX(calc(100% + 30px)" },
        },
      },
      // START
      animation: {
        slideInOut: "slideInOut 5s ease-in-out",
      },
      // END
    },
  },
  plugins: [],
};

每当我在tailwind.config.cjs中通过添加“animation”属性来扩展主题时,问题就会出现。如果我只删除这3行,一切都会正常。
我得到的输出(问题):

z5btuh9x

z5btuh9x1#

您的keyframes值中缺少右括号,因此当您添加animation配置时,它也会添加@keyframes定义并中断CSS的其余部分。请尝试以下修改:

slideInOut: {
  "0%": { transform: "translateX(calc(100% + 30px))" },
  "10%": { transform: "translateX(0)" },
  "90%": { transform: "translateX(0)" },
  "100%": { transform: "translateX(calc(100% + 30px))" },
},

相关问题