<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>div模拟textarea以实现高度自适应实例页面</title> </head> <style> .textarea_div { width: 100px; min-height: 20px; _height: 20px; max-height: 100px; line-height: 20px; margin:auto; padding: 4px; outline: 0; border: 1px solid purple; font-size: 12px; word-wrap: break-word; overflow-x: hidden; overflow-y: auto; -webkit-user-modify: read-write-plaintext-only; } </style> <body> <div class="textarea_div" contenteditable="true"></div> <script> if (typeof document.webkitHidden == "undefined") { // 非chrome浏览器阻止粘贴 box.onpaste = function() { return false; } } </script> </body> </html>
div模拟textarea以css控制最大高度和最小高度实现高度自适应实例页面
最新推荐文章于 2024-11-04 08:38:26 发布