css Html类不能与自定义Tailwind类一起使用

ih99xse1  于 2023-01-10  发布在  其他
关注(0)|答案(1)|浏览(199)

css:我的定制css文件

@tailwind base;
@tailwind components;
@tailwind utilities;

.event-button-secondary {
    height: 114px;
    max-width: 420px;
    @apply rounded-lg font-inter text-base-bold border-none bg-event-text-300 text-event-text-200 hover:bg-event-text-300 hover:text-event-text-200;
}

html页面:我在html标记中写入的“w-32”不起作用。

<button class="event-button-secondary w-32">Deactive</button>
8nuwlpux

8nuwlpux1#

我解决了它。如果你写!w-32而不是w-32,它会工作,但在Tailwind中,我们被要求在@layer中编写这样的类,以防止这种情况。所以如果你这样写:

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
 .event-button-secondary {
 height: 114px;
 max-width: 420px;
 @apply rounded-lg font-inter text-base-bold border-none bg-event-text-300 text- 
 event-text-200 hover:bg-event-text-300 hover:text-event-text-200;
 }
}

相关问题