使HTML标签可编辑 (在线编辑器) contenteditable

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线编辑器(contenteditable)</title>
<style>
div { width:500px; height:100px; word-wrap:break-word; word-break:normal; background:#F5F5F5; border:1px solid #EBEBEB; padding:10px 20px; font-size:14px; color:#333; line-height:24px; }
</style>
</head>

<body>
<div contenteditable="true">
设置标签属性contenteditable="true",即可在任何容器内输入内容,兼容所有浏览器。此方法结合CSS的word-wrap:break-word;(单词截断)及word-break:normal(允许在字内换行)可用来做在线编辑器。
</div>
</body>
</html>

你可能感兴趣的:(contenteditable)