首页 前端知识 Antd:修改自动完成输入框样式

Antd:修改自动完成输入框样式

2024-05-24 08:05:19 前端知识 前端哥 226 240 我要收藏

没有嵌套input输入框:

 <AutoComplete
    options={options}
    onSelect={onSelect}
    onSearch={onSearch}
    onChange={onChange}
    placeholder='请输入'
/>

// 设置输入框高度
@input-height: 40px;
.ant-select-auto-complete {
 width: 100%;
 .ant-select-selector {
   height: @input-height;
   background: rgba(0, 133, 255, 0.2);
   border: 1px solid #0085FF;
   .ant-select-selection-search {
     input {
       height: 100%;
       color: white;
     }
   }
   .ant-select-selection-placeholder {
     line-height: calc(@input-height - 2px);
   }
 }
}

实现效果:

嵌套input输入框(为了实现prefix或suffix)

<AutoComplete
  options={options}
  onSelect={onSelect}
  onSearch={onSearch}
  onChange={onChange}
>
  <Input prefix={<SearchOutlined />} placeholder='请输入'/>
</AutoComplete>

@input-height: 40px;
.ant-select-auto-complete {
  width: 100%;
  .ant-select-selector {
    .ant-select-selection-search-input {
      height: @input-height;
      background: rgba(0, 133, 255, 0.2);
      border: 1px solid #0085FF;
      .ant-input-prefix {
        margin-right: 16px;
        color: #0085FF;
      }
      input {
        line-height: calc(@input-height - 2px);
        color: white;
        background: transparent;
      }
    }
  }
}

实现效果

转载请注明出处或者链接地址:https://www.qianduange.cn//article/9289.html
标签
评论
发布的文章

用JS生成本周日期代码

2024-04-18 17:04:15

js 递归函数

2024-05-31 10:05:46

jQuery是什么?如何使用?

2024-03-12 01:03:24

js延迟加载的六种方式

2024-05-30 10:05:51

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!