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

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

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

  1. module.exports = {
  2. content: ["./index.html", "./src/**/*.{js,jsx}"],
  3. theme: {
  4. colors: {
  5. primary: "#E51114",
  6. secondary: "#434242",
  7. lightGray: "#CCCCCC",
  8. dimmedWhite: "#F5F5F5",
  9. white: "#FFFFFF",
  10. },
  11. extend: {
  12. keyframes: {
  13. slideInOut: {
  14. "0%": { transform: "translateX(calc(100% + 30px)" },
  15. "10%": { transform: "translateX(0)" },
  16. "90%": { transform: "translateX(0)" },
  17. "100%": { transform: "translateX(calc(100% + 30px)" },
  18. },
  19. },
  20. // START
  21. animation: {
  22. slideInOut: "slideInOut 5s ease-in-out",
  23. },
  24. // END
  25. },
  26. },
  27. plugins: [],
  28. };

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

z5btuh9x

z5btuh9x1#

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

  1. slideInOut: {
  2. "0%": { transform: "translateX(calc(100% + 30px))" },
  3. "10%": { transform: "translateX(0)" },
  4. "90%": { transform: "translateX(0)" },
  5. "100%": { transform: "translateX(calc(100% + 30px))" },
  6. },

相关问题