【发布时间】:2016-10-12 03:18:51
【问题描述】:
【问题讨论】:
-
你试过 input type="text" placeholder="test" 吗??
【问题讨论】:
<input placeholder="Your Date" type="text" onfocus="(this.type='date')" onblur="(this.type='text')" id="date">
阅读本页
How do I simulate placeholder functionality on input date field?
【讨论】:
var dateofbirth="01/23/1990";
document.getElementById('test').placeholder=dateofbirth;
【讨论】:
您可以将输入日期默认占位符与:before 元素重叠。
输入元素需要用onChange事件控制
/* When Input type="date" && value="" => hide Input content */
input[type="date"][value=""] {
position: relative;
height: 100%;
color: transparent;
transition: all 0.2s;
}
/* When focus show it*/
input[type="date"]:focus {
color: inherit;
}
/* Input type="date" && value="" => overlap with before */
input[type="date"][value=""]:before {
content: attr(placeholder);
position: absolute;
height: 100%;
width: calc(100% - 20px);
padding-top: 4px;
color: #aaa;
background-color: white;
transition: all 0.2s;
}
/* rid off before on focus */
input[type="date"]:focus:before {
content: none;
}
<input type="date" placeholder="My placeholder" value="" />
【讨论】:
http://www.htctu.net/html5/forms/formInputTypes.html#date 试试这个链接。
<input type=date form="sf1" name="date" placeholder="23-7-1988">
【讨论】: