Antd:如何自定义关闭图标和搜索图标样式?

发布于 2025-01-15 02:28:48 字数 935 浏览 1 评论 0原文

我在自定义关闭图标和搜索图标样式时遇到问题。 我想在输入左侧制作搜索图标,在输入右侧制作关闭图标。 但现在输入右侧有两个图标。

右侧带有 X 和搜索图标的搜索框,搜索图标部分位于搜索框之外

我怎样才能解决这个问题吗?

我的代码在这里

.ant-input {
            padding: 4px 10px 4px 40px;
            border-radius: 20px;
            &-search {
                height: 40px;
                width: 240px !important;
            }
            &-suffix {
                width: 18px;
                > i {
                    font-size: 18px;
                }
            }
        }
 }
<div className='user-list__tollbar--search'>
   <Search
        onChange={this.onSearch}
        style={{width: 200}}
        defaultValue={keyWord}
        allowClear
    />
</div>

I have a problem when custom close icon and search icon style.
I want to make search icon in left of input and close icon in right of input.
But now two icons is in right of input.

A search box with an X and search icon on the right, with the search icon partially outside of the search box

How can I fix this problem?

My code is here

.ant-input {
            padding: 4px 10px 4px 40px;
            border-radius: 20px;
            &-search {
                height: 40px;
                width: 240px !important;
            }
            &-suffix {
                width: 18px;
                > i {
                    font-size: 18px;
                }
            }
        }
 }
<div className='user-list__tollbar--search'>
   <Search
        onChange={this.onSearch}
        style={{width: 200}}
        defaultValue={keyWord}
        allowClear
    />
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的憧憬 2025-01-22 02:28:48

您可以使用 antd Input 来解决您的问题

<Input
  prefix={<SearchOutlined />}
  placeholder="Search"
  allowClear
/>

屏幕截图

You can use antd Input to solve your issue

<Input
  prefix={<SearchOutlined />}
  placeholder="Search"
  allowClear
/>

Screenshot

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文