我是一个初学者,我一直在研究 Angular 并决定使用 Tailwind 进行样式设计,因为每个 Tailwind 类都是内联的,按钮的样式类变得很大,为了使用该按钮,我必须使用该类到处。这使得代码看起来很繁琐并且维护变得很痛苦。
我的问题是如何使用 tailwind 使按钮样式全局化,我也有多种样式的按钮,例如 button-no-bg 、 button-bg-red p>
我尝试使用@apply指令在Angular的styles.css中定义它们
@tailwind base;
@tailwind components;
@tailwind utilities;
.button-no-bg{
@apply bg-white text-blue-500 border p-1 px-8 text-xs font-bold border-blue-500;
}
.button-red-bg{
@apply ......;
}
为了避免代码重复,我想知道如何使按钮类具有多个按钮名称及其关联类的全局性。如果不是完整答案,请分享参考。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号