如何更改 HTML 数据列表输入上显示的图标?隐藏是可能的,但我可以将其更改为其他一些图标,例如向下箭头

How to Change the icon which displays on the datalist input in HTML? Hiding is possible , but can i change it to some other icons, Like arrow-down?

本文关键字:图标 其他 我可以 数据 HTML 显示 输入 隐藏 何更改 列表      更新时间:2023-09-26

input::-webkit-calendar-picker-indicator {
  display: none;
}
<input type="date" />

这是隐藏它的代码。如何将图标更改为其他图标?

窍是使用opacity:0隐藏图标,然后您可以添加自己的图标。在这个简单的fontawesome我正在使用日历图标。

input::-webkit-calendar-picker-indicator {
  opacity:0;
}
input {
  position:relative;  
}
input:before {
  content: "'f073";
  display: inline-block;
  font: normal normal normal 14px/1 FontAwesome;
  font-size: inherit;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position:absolute;
  right:0;
  top:50%;
  transform:translateY(-50%);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<input type="date" />