resize.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CodeMirror: Autoresize Demo</title>
  6. <link rel="stylesheet" href="../lib/codemirror.css">
  7. <script src="../lib/codemirror.js"></script>
  8. <script src="../mode/css/css.js"></script>
  9. <link rel="stylesheet" href="../doc/docs.css">
  10. <style type="text/css">
  11. .CodeMirror {
  12. border: 1px solid #eee;
  13. height: auto;
  14. }
  15. .CodeMirror-scroll {
  16. overflow-y: hidden;
  17. overflow-x: auto;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <h1>CodeMirror: Autoresize demo</h1>
  23. <form><textarea id="code" name="code">
  24. .CodeMirror {
  25. border: 1px solid #eee;
  26. height: auto;
  27. }
  28. .CodeMirror-scroll {
  29. overflow-y: hidden;
  30. overflow-x: auto;
  31. }
  32. </textarea></form>
  33. <p>By setting a few CSS properties, and giving
  34. the <a href="../doc/manual.html#option_viewportMargin"><code>viewportMargin</code></a>
  35. a value of <code>Infinity</code>, CodeMirror can be made to
  36. automatically resize to fit its content.</p>
  37. <script>
  38. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  39. lineNumbers: true,
  40. viewportMargin: Infinity
  41. });
  42. </script>
  43. </body>
  44. </html>