-
-
Save esironal/2d04b171c5f453c4553d to your computer and use it in GitHub Desktop.
CodeMirror almost full height
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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