Skip to content

Instantly share code, notes, and snippets.

@esironal
Forked from marijnh/gist:4202141
Created October 16, 2015 01:26
Show Gist options
  • Select an option

  • Save esironal/2d04b171c5f453c4553d to your computer and use it in GitHub Desktop.

Select an option

Save esironal/2d04b171c5f453c4553d to your computer and use it in GitHub Desktop.
CodeMirror almost full height
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<link href="lib/codemirror.css" rel="stylesheet">
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
.wrap {
position: relative;
height: 100%;
background: #eee;
padding: 20px;
box-sizing: border-box;
}
.border {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border: 1px solid #999;
position: relative;
height: 100%;
padding: 1px;
}
.CodeMirror {
height: 100%;
background: white;
}
</style>
<script src="lib/codemirror.js"></script>
</head>
<body>
<div class=wrap><div class=border><textarea id="code"></textarea></div></div>
<script>
(function() {
// Create a CM instance
var ed = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
lineWrapping: false,
readOnly: true
});
var content = "foo\nbar\nbaz\nquux\n";
for (var i = 0; i < 10; ++i) content += content;
ed.setValue(content);
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment