使用tailwindcss与antd冲突,Button按钮透明

先看问题

image.png

问题出现的原因

原因是我们使用了tailwindcss ,默认情况会有tailwindcss的默认属性

代码块内我们发现 background-color: transparent; 这个是默认属性导致的

button, [type='button'], [type='reset'], [type='submit'] {
    -webkit-appearance: button;
    background-color: transparent;
    background-image: none;
}
<style>
button, [type='button'], [type='reset'], [type='submit'] {
    -webkit-appearance: button;
    background-color: transparent;
    background-image: none;
}

解决方案,禁止tailwindcss的默认属性

添加corePlugins对象,并设置preflightfalse

修改文件 tailwind.config.js

module.exports = {
  ...
  ...
  corePlugins: {
    preflight: false
  }
}

效果

image.png

如果有问题可以联系我 wx: faith1314666

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容