此乃借鉴别人的方法,自己也在学习
HTML代码: 选择日期: 选择时间: 选择星期: 选择月份:
目前WebKit下有如下9个伪元素可以改变日期控件的UI:
::-webkit-datetime-edit
::-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
::-webkit-calendar-picker-indicator
::-webkit-clear-button
以下的囊括了date,datetime,week,time所用的伪元素: input::-webkit-datetime-edit{} input::-webkit-datetime-edit-fields-wrapper{} input::-webkit-datetime-edit-ampm-field{} input::-webkit-datetime-edit-day-field{} input::-webkit-datetime-edit-hour-field{} input::-webkit-datetime-edit-millisecond-field{} input::-webkit-datetime-edit-minute-field{} input::-webkit-datetime-edit-month-field{} input::-webkit-datetime-edit-second-field{} input::-webkit-datetime-edit-week-field{} input::-webkit-datetime-edit-year-field{} input::-webkit-datetime-edit-ampm-field:focus{} input::-webkit-datetime-edit-day-field:focus{} input::-webkit-datetime-edit-hour-field:focus{} input::-webkit-datetime-edit-millisecond-field:focus{} input::-webkit-datetime-edit-minute-field:focus{} input::-webkit-datetime-edit-month-field:focus{} input::-webkit-datetime-edit-second-field:focus{} input::-webkit-datetime-edit-week-field:focus{} input::-webkit-datetime-edit-year-field:focus{} input::-webkit-datetime-edit-year-field[disabled]{} input::-webkit-datetime-edit-month-field[disabled]{} input::-webkit-datetime-edit-week-field[disabled]{} input::-webkit-datetime-edit-day-field[disabled]{} input::-webkit-datetime-edit-ampm-field[disabled]{} input::-webkit-datetime-edit-hour-field[disabled]{} input::-webkit-datetime-edit-millisecond-field[disabled]{} input::-webkit-datetime-edit-minute-field[disabled]{} input::-webkit-datetime-edit-second-field[disabled]{} input::-webkit-datetime-edit-text{} input::-webkit-inner-spin-button{} input::-webkit-calendar-picker-indicator{} input::-webkit-calendar-picker-indicator:hover{}
date类型改变行高和高度那个小三角并不会根据大小调整,实在太丑了,所以决定把它隐藏掉。 下面的css可以去掉date中上下小三角,但是保留input类型为number的小三角。 input[type=date]::-webkit-inner-spin-button { visibility: hidden; } input类型为date的输入框有以下属性,可以根据自己的需求自行调整。 ::-webkit-datetime-edit { padding: 1px; background: url(../selection.gif); } ::-webkit-datetime-edit-fields-wrapper { } ::-webkit-datetime-edit-text { color: #4D90FE; padding: 0 .3em; } ::-webkit-datetime-edit-year-field { color: purple; } ::-webkit-datetime-edit-month-field { color: blue; } ::-webkit-datetime-edit-day-field { color: green; } ::-webkit-inner-spin-button { visibility: hidden; } ::-webkit-calendar-picker-indicator { border: 1px solid #ccc; border-radius: 2px; box-shadow: inset 0 1px #fff, 0 1px #eee; background-image: -webkit-linear-gradient(top, #f0f0f0, #e6e6e6); color: #666; }