Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: 在引入 tailwindcss 后,Image 组件的预览样式会出现问题(预览的图片偏移了,都在左下角,且看不全了) ❌ #39913

Closed
wangrongding opened this issue Dec 30, 2022 · 8 comments · Fixed by #39914

Comments

@wangrongding
Copy link

Reproduction link

https://stackblitz.com/edit/vitejs-vite-s5eias

Steps to reproduce

打开这个链接后,点击加载出来的图片组件,可以看到,预览的图片样式出现问题

What is expected?

正常预览

What is actually happening?

预览样式存在问题(图片偏移了,都在左下角,且看不全了),应该是被 tailwind 影响了,index.css中只要不引入 下面的就没事。

@tailwind base;
@tailwind components;
@tailwind utilities; 
Environment Info
antd undefined
React 18.2.0
System macos
Browser chrome
@MadCcc
Copy link
Member

MadCcc commented Dec 30, 2022

@MadCcc MadCcc closed this as completed Dec 30, 2022
@zombieJ
Copy link
Member

zombieJ commented Dec 30, 2022

这个是 tailwind 重置 img 的 css 导致的,提高优先级不行。

@zombieJ zombieJ reopened this Dec 30, 2022
@wangrongding
Copy link
Author

这个是 tailwind 重置 img 的 css 导致的,提高优先级不行。

我也赞同这个说法,提高优先级的方式不能解决根本问题,而且关闭 :where 降权后会带来其他方面的问题。

@zombieJ
Copy link
Member

zombieJ commented Dec 30, 2022

我也赞同这个说法,提高优先级的方式不能解决根本问题,而且关闭 :where 降权后会带来其他方面的问题。

提高优先级是建议的解法,但是这个 issue 里提高没用。因为 antd 没有对 img 做过样式覆盖,提升了也没用。需要 antd 里补一份样式。

@wangrongding
Copy link
Author

提高优先级是建议的解法,但是这个 issue 里提高没用。因为 antd 没有对 img 做过样式覆盖,提升了也没用。需要 antd 里补一份样式。

期待后续被解决,在此感谢~🌸

@jaybowang
Copy link

jaybowang commented Jan 7, 2023

@wangrongding 关掉Tailwind preflight即可,https://tailwindcss.com/docs/preflight#disabling-preflight

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  // ...
  corePlugins: { preflight: false },
};

测试通过
https://stackblitz.com/edit/vitejs-vite-grnmth?file=tailwind.config.cjs

@wangrongding
Copy link
Author

@jaybowong 这将禁用 Tailwind 的全局基本样式,我需要它

@wangrongding
Copy link
Author

没事,问题已经被 antd 修复了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants