.CodeMirror { border: 1px solid #eee; height: auto; }
CodeMirror
Home Manual Code
Autoresize
Autoresize Demo
.CodeMirror { border: 1px solid #eee; height: auto; }
By setting an editor's height style to auto and giving the viewportMargin a value of Infinity , CodeMirror can be made to automatically resize to fit its content.
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, viewportMargin: Infinity });