Skip to content

Instantly share code, notes, and snippets.

@marijnh
Created December 4, 2012 09:23
Show Gist options
  • Save marijnh/4202141 to your computer and use it in GitHub Desktop.
Save marijnh/4202141 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>
@cu
Copy link

cu commented Apr 18, 2020

I don't know who you are, and you don't know me, but you just saved my bacon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment