最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Increase date input button clickable area - Stack Overflow

programmeradmin0浏览0评论

I have a date input element.

<input type="date" >

The following red square is the default area the button can be clicked to open the date picker:

I wonder if it is possible to increase this area to make it easier to click, something wider like this:

Solutions in html, javascript or css are ok.

I have a date input element.

<input type="date" >

The following red square is the default area the button can be clicked to open the date picker:

I wonder if it is possible to increase this area to make it easier to click, something wider like this:

Solutions in html, javascript or css are ok.

Share Improve this question edited Mar 7, 2022 at 22:01 TylerH 21.1k77 gold badges79 silver badges112 bronze badges asked Dec 11, 2020 at 13:53 straminstramin 2,4003 gold badges32 silver badges66 bronze badges 3
  • An input is clickable on its entire width by default, you don't have to specifically click the icon to open the calendar. Or maybe this is browser-dependent, which browser forces you to click the icon? – Teemu Commented Dec 11, 2020 at 13:58
  • I tried Chrome, Opera and Edge, I have to click in that area to open the date picker – stramin Commented Dec 11, 2020 at 14:04
  • Ah ... It seems to work differently in FF. – Teemu Commented Dec 11, 2020 at 14:16
Add a ment  | 

1 Answer 1

Reset to default 9

Try using ::-webkit-calendar-picker-indicator pseudo-element

#date-inp::-webkit-calendar-picker-indicator {
  padding-left: 100px;
  border: 1px dashed red;
}
<input type="date" id="date-inp"/>

发布评论

评论列表(0)

  1. 暂无评论