How to modify the html5 date style: 1. Create a separate css file and add the code as "::-webkit-datetime-edit { padding: 1px;} ::-webkit-datetime-edit-fields- wrapper {... }..."; 2. Control the specific time through "-webkit-datetime-edit-day-field".
The operating environment of this tutorial: Windows 10 system, HTML5 version, DELL G3 computer
How to modify the html5 date style?
Custom style for input[type='date'] in HTML5
HTML5 provides a calendar control function, which reduces development time, but sometimes it The style is indeed unsatisfactory, we can modify it ourselves according to the code below.
Suggestion: Copy the code snippet below and create a separate css file for our convenience.
/* 修改日历控件类型 */ ::-webkit-datetime-edit { padding: 1px;} /*控制编辑区域的*/ ::-webkit-datetime-edit-fields-wrapper { background-color: #fff; } /*控制年月日这个区域的*/ ::-webkit-datetime-edit-text { color: #333; padding: 0 .5em; } /*这是控制年月日之间的斜线或短横线的*/ ::-webkit-datetime-edit-year-field { color: #333; } /*控制年文字, 如2013四个字母占据的那片地方*/ ::-webkit-datetime-edit-month-field { color: #333; } /*控制月份*/ ::-webkit-datetime-edit-day-field { color: #333; } /*控制具体日子*/ ::-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-color: #eee; background-image: -webkit-linear-gradient(top, #f0f0f0, #e6e6e6); color: #666; } ::-webkit-clear-button { /*控制清除按钮*/ }
Modify the effect as shown below:
The effect css code is:
/* 修改日历控件类型 */ ::-webkit-datetime-edit { padding: 1px;color:#6be9ff;background:rgba(0,0,0,0);} /*控制编辑区域的*/ ::-webkit-datetime-edit-fields-wrapper { background-color: rgba(0,0,0,0);font-size:18px;line-height:34px;} /*控制年月日这个区域的*/ ::-webkit-datetime-edit-text { color: #6be9ff; padding:0; } /*这是控制年月日之间的斜线或短横线的*/ ::-webkit-datetime-edit-year-field { background-color: rgba(0,0,0,0);color: #6be9ff; } /*控制年文字, 如2013四个字母占据的那片地方*/ ::-webkit-datetime-edit-month-field { background-color: rgba(0,0,0,0);color: #6be9ff; } /*控制月份*/ ::-webkit-datetime-edit-day-field { background-color: rgba(0,0,0,0);color: #6be9ff; } /*控制具体日子*/ ::-webkit-inner-spin-button { visibility: hidden; } /*这是控制上下小箭头的*/ ::-webkit-calendar-picker-indicator { /*这是控制下拉小箭头的*/ //background-image: url("../../img/shuizhi/time_bg.png"); border: 1px solid #ccc; border-radius: 2px; box-shadow: inset 0 1px #fff, 0 1px #eee; background-color: #eee; background-image: -webkit-linear-gradient(top, #f0f0f0, #e6e6e6); color: #666; margin-right: 10px; } ::-webkit-clear-button { /*控制清除按钮*/ visibility: hidden; }
The only bad thing is that the small triangle cannot be replaced For your own pictures, if you want to make them better, you can use some time plug-ins.
Recommended study: "HTML Video Tutorial"
The above is the detailed content of How to modify the html5 date style. For more information, please follow other related articles on the PHP Chinese website!