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