resize.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!doctype html>
  2. <title>CodeMirror: Autoresize Demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <script src="../lib/codemirror.js"></script>
  7. <script src="../mode/css/css.js"></script>
  8. <style type="text/css">
  9. .CodeMirror {
  10. border: 1px solid #eee;
  11. height: auto;
  12. }
  13. </style>
  14. <div id=nav>
  15. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  16. <ul>
  17. <li><a href="../index.html">Home</a>
  18. <li><a href="../doc/manual.html">Manual</a>
  19. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  20. </ul>
  21. <ul>
  22. <li><a class=active href="#">Autoresize</a>
  23. </ul>
  24. </div>
  25. <article>
  26. <h2>Autoresize Demo</h2>
  27. <form><textarea id="code" name="code">
  28. .CodeMirror {
  29. border: 1px solid #eee;
  30. height: auto;
  31. }
  32. </textarea></form>
  33. <p>By setting an editor's <code>height</code> style
  34. to <code>auto</code> and giving
  35. the <a href="../doc/manual.html#option_viewportMargin"><code>viewportMargin</code></a>
  36. a value of <code>Infinity</code>, CodeMirror can be made to
  37. automatically resize to fit its content.</p>
  38. <script>
  39. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  40. lineNumbers: true,
  41. viewportMargin: Infinity
  42. });
  43. </script>
  44. </article>