HTML5 默认点击输入框显示日历
仅限桌面端
<hr>
默认日期输入框 - 点击图标
通常情况下,如果我们使用 HTML5 的 date 输入框,必须点击图标才能弹出日历。
<input type="date">
点击输入框任意位置弹出日历
<input type="date">
<style>
input[type="date"].field-enhance::-webkit-calendar-picker-indicator {
background: transparent;
bottom: 0;
color: transparent;
cursor: pointer;
height: auto;
left: 0;
position: absolute;
right: 0;
top: 0;
width: auto;
}
</style>
要在点击输入框时弹出日历,请使用以下代码:
<pre data-lang="CSS"><code>.input-container input {
border: none;
box-sizing: border-box;
outline: 0;
padding: .75rem;
position: relative;
width: 100%;
}
input[type="date"]::-webkit-calendar-picker-indicator {
background: transparent;
bottom: 0;
color: transparent;
cursor: pointer;
height: auto;
left: 0;
position: absolute;
right: 0;
top: 0;
width: auto;
}</code></pre>