现在很多网站比如知乎的评论功能都是用div而不是textarea。
但如果我按照下面这样做的话,会存在鼠标不会像真正的placeholder那样和文字对齐的情况。请问知乎是怎么实现的,怎样避免出现我这种情况?
Stackoverflow上面一个类似的问题,line-height:normal也解决不了问题
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
div {
width:600px;
border: 1px solid red;
// line-height: normal;
line-height: 200%;
padding-left: 5px;
}
div:empty:before {
content: attr(placeholder);
display: block;
color: #999;
}
</style>
</head>
<body>
<div contenteditable="true" placeholder="输入用户名"></div>
</body>
</html>
ABOUTYOU
相关分类