Search code examples
javascripthtmlsizecodemirror

Dynamical size of textarea


I'm using CodeMirror 2 editor. The trouble is that I can't make it fullsize (100%; 100%). I added to the main style:

.CodeMirror {
    height: 100%;
    width: 100%;
}

And this doesn't work for me in any browser. Any ways?


Solution

  • I'm using the following code in http://jsbin.com to stretch the CodeMirror frame (note that JS Bin in particular stretches to half screen width, but the example code below does "fullscreen"):

    .CodeMirror {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }
    

    I don't remember whether CodeMirror adds the class by default, but if it doesn't, you'll also want to add it in the JavaScript (assuming you've not solved this already):

    CodeMirror.fromTextArea('ID_OF_TEXTAREA', {
      // .. some other options...
      iframeClass: 'CodeMirror'
    });