用于在 Chrome 中设置 HTML5 日期输入日历样式的 CSS

标签 css html google-chrome date input

如果单击 html5 日期输入上的向下箭头,是否可以设置弹出日历的样式?

<form>
    <label for="f-duedate">Due date</label>
        <input id="f-duedate" type="date" name="duedate"
               data-date-format="dd.mm.YYYY">
</form>

a html5 calendar

http://jsfiddle.net/no8a17eo/1/

我知道有伪选择器可以为输入字段本身设置样式:

::-webkit-datetime-edit-fields-wrapper {
}
::-webkit-datetime-edit-text {
}
::-webkit-datetime-edit-month-field, 
::-webkit-datetime-edit-day-field, 
::-webkit-datetime-edit-year-field {
}
::-webkit-inner-spin-button {
    display: none;
}
::-webkit-calendar-picker-indicator:hover {
   background:none;
}

至少我只需要它在最新版本的 Google Chrome 上工作

最佳答案

根据Google的FAQ,目前没有办法修改样式: https://developers.google.com/web/updates/2012/08/Quick-FAQs-on-input-type-date-in-Google-Chrome

How do I change the appearance of the date picker?

You cannot currently style the appearance of the date picker. In WebKit, we have previously provided ways to style form controls with the -webkit-appearance CSS property or the ::-webkit-foo pseudo class selector. However the calendar popup does not provide such ways in WebKit because it is separate from the document, like a popup menu for , and there is not currently a standard for how to control styling on its sub-elements.

你只能继续使用 Chrome 的渲染,或者在 input type="text" 字段上使用自定义库来防止冲突

关于用于在 Chrome 中设置 HTML5 日期输入日历样式的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28738112/

相关文章:

javascript - 将一个 div 居中,让 children 向左浮动

css - 背景图片在 github 页面上不起作用

html - body 奇怪的额外顶部空间

google-chrome - 通过脚本在 Chrome 上设置默认搜索提供程序

html - chrome 不尊重 flexbox 中的图像纵横比

javascript - 如何让我的导航栏在滚动时变成半透明?

javascript - 下拉项目文本更改选择

javascript - 查询 : link title attribute unchange

html - 使图像忽略CSS中的颜色动画

javascript - 未捕获的语法错误 : Unexpected token : in chrome