div 实现 placeholder

2017-08-12  本文已影响0人  静候那一米阳光
<style>
[placeholder]:empty:before {
  content: attr(placeholder);
  color: #999;
}

[placeholder]:empty:focus:before {
  content: "";
}
</style>

<div placeholder="please input"></div>

配合 contenteditable

<div contenteditable="true" placeholder="please input..." style="border:1px solid #ccc"></div>

拓展阅读:Placeholder for contenteditable div——Stack Overflow

上一篇下一篇

猜你喜欢

热点阅读