输出---修改ant样式

一、修改ant design里面的样式

最近有一个公司的任务就是要去基于antdesign修改样式,之前都是ai修改的,这一次学到了很多:

大概的思路就是要先去文档里面查找将修改样式的类放在什么地方→控制台样式里面找对应的样式→对样式进行编写

以日期选择器为例子:

其实我根本没有找到修改样式的类应该放在哪里,我也是在网上搜寻才知道的 dropdownClassName

使用css in js语法把对应的类添加在里面就可以了。

jsx 复制代码
 <RangePicker
               dropdownClassName={styles.TimePickerPanel}
               className={styles.TimePicker}
               value={selectedDates} // 使用value作为受控组件
               onChange={(dates) => {
                 if (dates) {
                   setSelectedDates(dates as [dayjs.Dayjs, dayjs.Dayjs]);
                 }
               }}
               showTime={{
                 format: 'HH:mm:ss',
                 defaultValue: [dayjs().hour(0).minute(0).second(0), dayjs().hour(23).minute(59).second(59)]
               }}
               style={{
                 backgroundColor: 'rgba(36, 68, 110, 0.82)',
                 color: '#C0C2C4',
               }}
             />

然后就是找样式了:

就是要这样一个个去寻找对应的样式,而且还要注意是否嵌套,注意层级和优先级

一些样式代码:

tsx 复制代码
  .graphic-ant-picker-cell-selected .graphic-ant-picker-cell-inner,
        .graphic-ant-picker-cell-range-end .graphic-ant-picker-cell-inner,
        .graphic-ant-picker-cell-range-hover-end
          .graphic-ant-picker-cell-inner {
          background-color: #7ec2ff !important;
          color: #000 !important;
        }
tsx 复制代码
   /* 同时针对伪元素设置样式 */
        .graphic-ant-picker-range-arrow::before,
        .graphic-ant-picker-range-arrow::after {
          display: none !important;
          content: none !important;
          width: 0 !important;
          height: 0 !important;
        }

也可以找到修改的地方复制元素和样式交给ai修改

Dropdown:

tsx 复制代码
<Dropdown
               menu={{
                 items: menuItems,
               }}
               overlayClassName={styles.DropdownMenu}
               >
               <button className={styles.DropdownButton}>
                 {menuItems[0].label}
               </button>
             </Dropdown>
相关推荐
该用户已不存在4 小时前
这6个网站一旦知道就离不开了
前端·后端·github
Ai行者心易4 小时前
10天!前端用coze,后端用Trae IDE+Claude Code从0开始构建到平台上线
前端·后端
东东2334 小时前
前端开发中如何取消Promise操作
前端·javascript·promise
掘金安东尼4 小时前
官方:什么是 Vite+?
前端·javascript·vue.js
柒崽4 小时前
ios移动端浏览器,vh高度和页面实际高度不匹配的解决方案
前端
烛阴4 小时前
为什么游戏开发者都爱 Lua?零基础快速上手指南
前端·lua
大猫会长4 小时前
tailwindcss出现could not determine executable to run
前端·tailwindcss
Moonbit4 小时前
MoonBit Pearls Vol.10:prettyprinter:使用函数组合解决结构化数据打印问题
前端·后端·程序员
533_5 小时前
[css] border 渐变
前端·css