代码如下:
1 1 DOCTYPE html >
2 2 html lang ="en" >
3 3 head >
4 4 meta charset ="UTF-8" >
5 5 title > div模拟textarea自适应高度le>
6 6 style type ="text/css" >
7 7 .test_box {
8 8 width : 500px ;
9 9 min-height : 200px ;
10 10 max-height : 600px ;
11 11 _height : 200px ; /* 兼容IE6浏览器 */
12 12 margin : 0 auto ;
13 13 padding : 3px ;
14 14 outline : 0 ;
15 15 border : 1px solid #e4e4e4 ;
16 16 font-size : 12px ;
17 17 word-wrap : break-word ; /* 用于英文文本自动换行,所有主流浏览器支持 */
18 18 overflow-x : hidden ;
19 19 overflow-y : auto ;
20 20 -webkit-user-modify : read-write-plaintext-only ;
21 21 }
22 22 style >
23 23 head >
24 24 body >
25 25 div class ="test_box" contenteditable ="true" > 我是模拟textarea的div div >
26 26 script type ="text/javascript" >
27 27 if ( typeof document.webkitHidden == " undefined " ) {
28 28 // 非chrome浏览器阻止粘贴
29 29 box.onpaste = function () {
30 30 return false ;
31 31 }
32 32 }
33 33 script >
34 34 body >
35 35 html >
查看更多关于div模拟textarea自适应高度-DTBelieve的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did115571