如何在Chrome中移除<input type=date>悬停时的箭头

3
我已经创建了一个日期选择器作为按钮,当在Chrome浏览器中悬停它时,它看起来很混乱。可能原因只是因为它在浏览器中的默认行为,但我可以改变Chrome上的悬停效果吗? Firefox中的图像: 默认<input type=date>

enter image description here

按钮 <input type=date>

enter image description here

在Chrome中的图片:

默认的<input type=date>(悬停时)

enter image description here

按钮 <input type=date>(悬停时)

enter image description here

有没有办法在Chrome上去掉那个悬停效果?

.date-picker-button {
  background: #8DBF42;
  color: #fff;
  position: relative;
  cursor: pointer;
  margin-bottom: 10px;
  border: 2px solid #8DBF42;
  font-size: 14px;
  padding: 12px;
  border-radius: 3px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  -o-border-radius: 3px;
  width: 300px;
}

.input-group {
  position: relative;
  border: 2px solid #cdd7e1;
  margin-bottom: 10px;
  display: block !important;
  width: 300px;
  border: none;
}

.date-picker-button .date-picker-input {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: 0;
  background: #8DBF42;
  border: none;
  width: 300px;
  padding-left: 55px;
}

.fa.fa-angle-down {
  float: right;
  color: white;
  font-size: 20px !important;
  font-weight: 600;
  top: 0px !important;
  position: relative;
  margin-right: 20px;
}

.fa-calendar-o {
  color: white !important;
  z-index: 1;
  top: 0px !important;
  position: relative !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="date-picker-button input-group">
  <i class="fa fa-calendar-o" aria-hidden="true"></i>
  <span>Select Date</span>
  <input class="input-startdate date-picker-input hasDatepicker" name="effdate" id="dp1523936970319" aria-required="true" required="" type="date">
  <i class="fa fa-angle-down" aria-hidden="true"></i>
</div>


1
你看过这个吗?https://stackoverflow.com/questions/22909969/styling-inputtype-date-in-chrome - Magd Kudama
3
你能添加你的CSS样式吗? - benams
@benams 我已经发布了 CSS,请看一下。 - Khushbu Vaghela
1
Bootstrap提供了日期选择器的自定义功能。您可以在以下链接中找到文档:https://eonasdan.github.io/bootstrap-datetimepicker/。我在我的几个Web应用程序中使用过它,它可以在IE、Edge和Chrome上运行。 - slee423
1
改变点击的方式是行为,而不是外观。不幸的是,在标准的<input type="date" />上改变行为的跨浏览器方法非常不可能。因此,最好调整一些第三方实现,如bootstrap、jQuery UI等。 - Vadim Ovchinnikov
3个回答

6
尝试这个,它会隐藏所有内容:

尝试这个,它会隐藏所有内容:

input#myInput::-webkit-calendar-picker-indicator { display: none }

input[type=date]::-webkit-inner-spin-button, 
input[type=date]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

箭头会隐藏,但日期选择器在Chrome中不显示。 - Khushbu Vaghela
因为日期选择器只会在点击下箭头后才显示。 - Khushbu Vaghela
1
如果您需要箭头,请忽略第一行。 - Delowar Hosain
我不需要箭头..在Chrome浏览器中,是否可以在单击按钮的任何位置显示日期选择器? - Khushbu Vaghela
非常感谢,我已经更改了我的元素并提供了所需的CSS,这很有帮助。 - Khushbu Vaghela

2

这段代码可以隐藏输入按钮:

::-webkit-inner-spin-button,
::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
}
<input type="date"  id="myInput">


箭头会隐藏,但日期选择器在Chrome中不显示。 - Khushbu Vaghela
因为日期选择器只会在点击下箭头后才显示。 - Khushbu Vaghela
1
@KhushbuVaghela 如果您提供CSS以重现此问题,修复将变得更加容易。 - Vadim Ovchinnikov
请查看此处 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/date - Andrei Todorut
@VadimOvchinnikov 我用 CSS 编辑了问题,请在 Chrome 上查看。 - Khushbu Vaghela

1

它运行得很好,但我已经更改了我的元素。谢谢。:) - Khushbu Vaghela

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接