div模拟实现textarea效果
程序员文章站
2022-07-12 20:14:46
...
效果展示:
代码实现:
<!DOCTYPE html>
<html>
<head>
<title>div实现textarea效果</title>
<style>
#textarea {
height: 200px;
width: 300px;
padding: 4px;
border: 1px solid #888;
resize: vertical;
overflow: auto;
}
#textarea:empty:before {
content: attr(placeholder);
color: #bbb;
}
</style>
</head>
<body>
<div id="textarea" contenteditable="true" placeholder="请输入内容..."></div>
</body>
</html>