ant-design / antd-style

css-in-js library with antd v5 token system
https://ant-design.github.io/antd-style/
MIT License
187 stars 29 forks source link

🧐[问题]怎么修改像 Drawer, message 这种存在 rootClassName 的组件的样式 #153

Closed wangchaoHeart closed 2 weeks ago

wangchaoHeart commented 2 weeks ago

🧐 问题描述

💻 示例代码

🚑 其他信息

arvinxx commented 2 weeks ago

没区别啊,直接写就好了

wangchaoHeart commented 2 weeks ago

根本不行, 假如我们现在要修改 antd组件Dropdown下来选项的选中样式,我们可以发现下拉选项是渲染在下图1的位置,我们根本没法用class选中它,没法修改 image

wangchaoHeart commented 2 weeks ago

image 我的需求就是 修改Table表头的过滤下拉框的样式,根本改不了

arvinxx commented 2 weeks ago

不是有popupClassname 么?挂那个啊

wangchaoHeart commented 2 weeks ago

不是有popupClassname 么?挂那个啊 Table上的默认过滤弹框怎么挂载? 重写他的过滤弹框吗? image

arvinxx commented 2 weeks ago

这个你去看下 Table 有没有给出这个 className ? 和 antd-style 似乎没啥关系。

wangchaoHeart commented 2 weeks ago

antd-style 库的作用 是在js中写css 怎么会没关系那?

arvinxx commented 2 weeks ago

@wangchaoHeart 如果 Table 这个 filter 面板,antd 本身也没有给出 className ,那么你用其他 css 方案(less 、 scss) 不是也没法覆写么?

wangchaoHeart commented 2 weeks ago

Table的filter面板有classname,其他css方案(less等)可以直接写样式覆盖antd的样式。 但是antd-style不行,antd-style必须挂载到一个dom元素上,且只能修改这个元素和子元素的样式,但是Table的filter面板是渲染在顶层的,所以没法修改

wangchaoHeart commented 2 weeks ago

Screenshot_2024-06-20-22-12-33-479_com.android.browser.jpg 就如同我截图一样,Table是渲染在2中的,但是当你打开Table的filter面板,你会发现面板是渲染在1中的,所以antd-style写的样式不生效

wangchaoHeart commented 2 weeks ago

不知道我描述的是否清清晰,是否需要我搞一个在线代码?

arvinxx commented 2 weeks ago

Table的filter面板有classname,其他css方案(less等)可以直接写样式覆盖antd的样式。

其他样式方案如果用css modules 不一样得挂到某个 className 上吗?如果不挂到某个className ,就要用全局作用域的覆写。在antd-style 里你要用全局覆写的话可以用 createGlobalStyle 呗

wangchaoHeart commented 2 weeks ago

Table的filter面板有classname,其他css方案(less等)可以直接写样式覆盖antd的样式。

其他样式方案如果用css modules 不一样得挂到某个 className 上吗?如果不挂到某个className ,就要用全局作用域的覆写。在antd-style 里你要用全局覆写的话可以用 createGlobalStyle 呗

太感谢了,终于解决了我的问题, 我要找的就是全局覆盖的写法,经测试 createGlobalStyle可以解决我的需求