Html中用div标签代替textarea标签实现类型office中文本框的效果(自适应高、宽)

<div contenteditable="true" 

  style="width: 400px; 

    min-height: 120px; 
    max-height: 300px;
    _height: 120px; 
    margin-left: auto; 
    margin-right: auto; 
    padding: 3px; 
    outline: 0; 
    border: 1px solid #a0b3d6; 
    font-size: 12px; 
    word-wrap: break-word;
    overflow-x: hidden;
    overflow-y: auto;

    -webkit-user-modify: read-write-plaintext-only;"></div>

Html代码如下

<!DOCTYPE html >
<html>
<head>
<style ></style>
</head>
<body>
    <div contenteditable="true" style="width: 400px; 
        min-height: 120px; 
        max-height: 300px;
        _height: 120px; 
        margin-left: auto; 
        margin-right: auto; 
        padding: 3px; 
        outline: 0; 
        border: 1px solid #a0b3d6; 
        font-size: 12px; 
        word-wrap: break-word;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-user-modify: read-write-plaintext-only;">
    <span style="font-family:'Times New Roman';color:rgb(0,112,192);font-weight:bold;font-size:11.0000pt;">text</span>
    </div>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/mengjiulong/p/9086973.html
今日推荐