<span style=
"color: #008080;"
> 1</span> 1 <span style=
"color: #0000ff;"
><span style=
"color: #ff00ff;"
>DOCTYPE html</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
> 2</span> 2 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>html </span><span style=
"color: #ff0000;"
>lang</span><span style=
"color: #0000ff;"
>=
"en"
</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
> 3</span> 3 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>head</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
> 4</span> 4 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>meta </span><span style=
"color: #ff0000;"
>charset</span><span style=
"color: #0000ff;"
>=
"UTF-8"
</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
> 5</span> 5 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>title</span><span style=
"color: #0000ff;"
>></span><span style=
"color: #000000;"
>div模拟textarea自适应高度le>
</span><span style=
"color: #008080;"
> 6</span> 6 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>style </span><span style=
"color: #ff0000;"
>type</span><span style=
"color: #0000ff;"
>=
"text/css"
</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
> 7</span> <span style=
"background-color: #f5f5f5; color: #800000;"
> 7 .test_box</span><span style=
"background-color: #f5f5f5; color: #000000;"
>{</span>
<span style=
"color: #008080;"
> 8</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
> 8 width</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>500px</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
> 9</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
> 9 min-height</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>200px</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>10</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>10 max-height</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>600px</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>11</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>11 _height</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>200px</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span><span style=
"background-color: #f5f5f5; color: #008000;"
>
</span>
<span style=
"color: #008080;"
>12</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>12 margin</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>0 auto</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>13</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>13 padding</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>3px</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>14</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>14 outline</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>0</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>15</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>15 border</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>1px solid #e4e4e4</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>16</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>16 font-size</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>12px</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>17</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>17 word-wrap</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>
break
-word</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span><span style=
"background-color: #f5f5f5; color: #008000;"
>
</span>
<span style=
"color: #008080;"
>18</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>18 overflow-x</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>hidden</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>19</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>19 overflow-y</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>auto</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>20</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>20 -webkit-user-modify</span><span style=
"background-color: #f5f5f5; color: #000000;"
>:</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
> read-write-plaintext-only</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;</span>
<span style=
"color: #008080;"
>21</span> <span style=
"background-color: #f5f5f5; color: #ff0000;"
>21 </span><span style=
"background-color: #f5f5f5; color: #000000;"
>}</span>
<span style=
"color: #008080;"
>22</span> <span style=
"background-color: #f5f5f5; color: #800000;"
>22 </span><span style=
"color: #0000ff;"
></span><span style=
"color: #800000;"
>style</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>23</span> 23 <span style=
"color: #0000ff;"
></span><span style=
"color: #800000;"
>head</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>24</span> 24 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>body</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>25</span> 25 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>div </span><span style=
"color: #ff0000;"
>
class
</span><span style=
"color: #0000ff;"
>=
"test_box"
</span><span style=
"color: #ff0000;"
> contenteditable</span><span style=
"color: #0000ff;"
>=
"true"
</span><span style=
"color: #0000ff;"
>></span>我是模拟textarea的div<span style=
"color: #0000ff;"
></span><span style=
"color: #800000;"
>div</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>26</span> 26 <span style=
"color: #0000ff;"
><span style=
"color: #800000;"
>script </span><span style=
"color: #ff0000;"
>type</span><span style=
"color: #0000ff;"
>=
"text/javascript"
</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>27</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>27</span> <span style=
"background-color: #f5f5f5; color: #0000ff;"
>
if
</span><span style=
"background-color: #f5f5f5; color: #000000;"
> (</span><span style=
"background-color: #f5f5f5; color: #0000ff;"
>typeof</span><span style=
"background-color: #f5f5f5; color: #000000;"
> document.webkitHidden </span><span style=
"background-color: #f5f5f5; color: #000000;"
>==</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>
"</span><span style="
background-color: #f5f5f5; color: #000000;
">undefined</span><span style="
background-color: #f5f5f5; color: #000000;
">"
</span><span style=
"background-color: #f5f5f5; color: #000000;"
>) {
</span><span style=
"color: #008080;"
>28</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>28</span> <span style=
"background-color: #f5f5f5; color: #008000;"
>
<span style=
"color: #008080;"
>29</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>29</span><span style=
"background-color: #f5f5f5; color: #000000;"
> box.onpaste </span><span style=
"background-color: #f5f5f5; color: #000000;"
>=</span> <span style=
"background-color: #f5f5f5; color: #0000ff;"
>
function
</span><span style=
"background-color: #f5f5f5; color: #000000;"
>() {
</span><span style=
"color: #008080;"
>30</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>30</span> <span style=
"background-color: #f5f5f5; color: #0000ff;"
>
return
</span> <span style=
"background-color: #f5f5f5; color: #0000ff;"
>false</span><span style=
"background-color: #f5f5f5; color: #000000;"
>;
</span><span style=
"color: #008080;"
>31</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>31</span><span style=
"background-color: #f5f5f5; color: #000000;"
> }
</span><span style=
"color: #008080;"
>32</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>32</span><span style=
"background-color: #f5f5f5; color: #000000;"
> }
</span><span style=
"color: #008080;"
>33</span> <span style=
"background-color: #f5f5f5; color: #000000;"
>33</span> <span style=
"color: #0000ff;"
></span><span style=
"color: #800000;"
>script</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>34</span> 34 <span style=
"color: #0000ff;"
></span><span style=
"color: #800000;"
>body</span><span style=
"color: #0000ff;"
>></span>
<span style=
"color: #008080;"
>35</span> 35 <span style=
"color: #0000ff;"
></span><span style=
"color: #800000;"
>html</span><span style=
"color: #0000ff;"
>></span></span></span></span></span></span></span></span></span></span>