placeholder 是 html5<input>的一个属性,它提供可描述输入字段预期值的提示信息(hint),该提示会在输入字段为空时显示
content 属性与 :before 及 :after 伪元素配合使用,给非input元素插入生成内容。
<div class="taglist" placeholder="你好"></div>
<style>
.taglist:empty::before {
color:lightgrey;
font-size:small;
content:attr(placeholder)
}
</style>
效果:在div里实现placeholder,输入内容后”你好“会自动隐藏
参考链接: