div变成输入框

 <style>
        #test{
            width: 150px;;
            min-height:20px;
            max-height:70px;
            outline: 0;
            border: 1px solid #000;
            font-size: 13px;
            overflow-x: hidden;
            overflow-y: auto;
            -webkit-user-modify: read-write-plaintext-only;
        }
        [contentEditable=true]:empty:not(:focus):before{
            content:attr(data-text);
        }
    </style>
</head>
<body>
<div id="test" contenteditable="true" data-text="输入留言"></div>

</body>

 

posted @ 2017-07-13 14:31  安静、、、  阅读(2500)  评论(0编辑  收藏  举报