【发布时间】:2018-10-05 13:20:36
【问题描述】:
我已经将日期选择器创建为一个按钮,当它悬停时,它在 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>
【问题讨论】:
-
你能添加你的css样式吗?
-
@benams 我已经发布了 css 请看一下
-
Boostrap 为日期选择器提供自定义。您可以通过以下链接找到文档:eonasdan.github.io/bootstrap-datetimepicker。我在一些网络应用程序中使用了它,它可以在 IE、Edge 和 Chrome 上运行。
-
改变点击的工作方式是行为,而不是外观。不幸的是,您不太可能通过跨浏览器方式更改标准
<input type="date" />上的行为。所以最好调整一些 3rd 方的实现,比如 bootstrap、jQuery UI 等。
标签: css html datepicker html5-input-date