我创建了日期选择器作为按钮,当悬停它时,它在Chrome浏览器中看起来很乱。可能原因只是因为它在浏览器中的默认行为,但我可以改变对Chrome的悬停效果吗?
Fire Fox中的图片:
默认<input type=date>
按钮<input type=date>
Chrome中的图片:
默认<input type=date>
(悬停时)
按钮<input type=date>
(悬停时)
有没有办法删除对chrome的悬停效果?
默认输入:
<input type="date" id="myInput">
使用CSS编辑:
.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>
答案 0 :(得分:2)
这样可以隐藏输入按钮:
::-webkit-inner-spin-button,
::-webkit-calendar-picker-indicator {
display: none;
-webkit-appearance: none;
}
&#13;
<input type="date" id="myInput">
&#13;
答案 1 :(得分:2)
试试这个,它会隐藏一切:
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;
}
答案 2 :(得分:1)
您可以按照以下答案:Method to show native datepicker in Chrome显示如何在整个输入中拉伸箭头,然后允许点击输入字段中的任意位置以触发日期选择器。