我有以下内容:FIDDLE
占位符可以很好地工作,直到您输入ctrl+A和为止delete。如果这样做,则占位符将消失并且不再显示。
怎么了?如何为内容可编辑的div使用占位符?
HTML:
<div class="test" placeholder="Type something..." contenteditable="true"></div>
CSS:
.test {
width: 500px;
height: 70px;
background: #f5f5f5;
border: 1px solid #ddd;
padding: 5px;
}
.test[placeholder]:empty:before {
content: attr(placeholder);
color: #555;
}
谢谢。