首页 > 开发 > HTML > 正文

input标签的type为date,显示的日期格式样式更改

2017-09-09 13:18:32  来源: 网友分享

nput标签的type为date,显示的日期格式样式默认是年/月/日,怎么改为年-月-日这种样式???
网上搜了,说是这个-webkit-datetime-edit-text,那在css里如何使用呢???麻烦大家解答一下

——————————————————————————————————————————————————————————————————————————————————

谢谢大家,感觉日期这种东西还是用插件更好一些,不过用text类型覆盖真的能解决很多问题,陌路凡歌的解答最接近我想要的结果,非常感谢大家,听诸君一席话,胜读十年书。

解决方案

这个///是改不了---的,这是谷哥自带的功能样式,只能改颜色背景色等,如果要那种效果可以用日历插件
有个取巧的方法,一个不能改的input覆盖在input type="date"上面

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><style>    *{        margin: 0;        padding: 0;    }    #div{        width: 500px;        height: 300px;        border: 2px solid #ccc;         position: absolute;     }    .datebox{        width: 150px;        position: relative;        height: 24px;        margin: 100px;    }    #date{        position: absolute;        left: 1px;        top: 1px;        z-index: 50;        width: 100px;        height: 100%;        height: 22px;                border: 1px solid transparent;    }    .mydate{        width: 150px;        height: 24px;        border: 1px solid #CCC;    }</style></head><body>    <div class="datebox">        <input type="text" id="date" readonly="readonly"/>        <input type="date" class="mydate" onchange="aaa(this)"/>    </div>    <script type="text/javascript">    function aaa(obj){        document.getElementById('date').value = obj.value;           }    </script></body></html>