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

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

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

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


收到一只叮咚
浏览 8749回答 1
1回答

呼啦一阵风

这个///是改不了---的,这是谷哥自带的功能样式,只能改颜色背景色等,如果要那种效果可以用日历插件有个取巧的方法,一个不能改的input覆盖在input type="date"上面<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><style>&nbsp; &nbsp; *{&nbsp; &nbsp; &nbsp; &nbsp; margin: 0;&nbsp; &nbsp; &nbsp; &nbsp; padding: 0;&nbsp; &nbsp; }&nbsp; &nbsp; #div{&nbsp; &nbsp; &nbsp; &nbsp; width: 500px;&nbsp; &nbsp; &nbsp; &nbsp; height: 300px;&nbsp; &nbsp; &nbsp; &nbsp; border: 2px solid #ccc;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; position: absolute;&nbsp;&nbsp; &nbsp; }&nbsp; &nbsp; .datebox{&nbsp; &nbsp; &nbsp; &nbsp; width: 150px;&nbsp; &nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; &nbsp; &nbsp; height: 24px;&nbsp; &nbsp; &nbsp; &nbsp; margin: 100px;&nbsp; &nbsp; }&nbsp; &nbsp; #date{&nbsp; &nbsp; &nbsp; &nbsp; position: absolute;&nbsp; &nbsp; &nbsp; &nbsp; left: 1px;&nbsp; &nbsp; &nbsp; &nbsp; top: 1px;&nbsp; &nbsp; &nbsp; &nbsp; z-index: 50;&nbsp; &nbsp; &nbsp; &nbsp; width: 100px;&nbsp; &nbsp; &nbsp; &nbsp; height: 100%;&nbsp; &nbsp; &nbsp; &nbsp; height: 22px;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; border: 1px solid transparent;&nbsp; &nbsp; }&nbsp; &nbsp; .mydate{&nbsp; &nbsp; &nbsp; &nbsp; width: 150px;&nbsp; &nbsp; &nbsp; &nbsp; height: 24px;&nbsp; &nbsp; &nbsp; &nbsp; border: 1px solid #CCC;&nbsp; &nbsp; }</style></head><body>&nbsp; &nbsp; <div class="datebox">&nbsp; &nbsp; &nbsp; &nbsp; <input type="text" id="date" readonly="readonly"/>&nbsp; &nbsp; &nbsp; &nbsp; <input type="date" class="mydate" onchange="aaa(this)"/>&nbsp; &nbsp; </div>&nbsp; &nbsp; <script type="text/javascript">&nbsp; &nbsp; function aaa(obj){&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById('date').value = obj.value;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; }&nbsp; &nbsp; </script></body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript