javascript - CodeMirror doesn't scroll down completely, Cursor is hidden behind div -


i use excellent texteditor codemirror in fullscreen mode in browser window , add fixed header kind of menu - or @ least space few buttons functionality.

so i've added div "position: fixed" top , added padding-top div codemirror object. problem comes up, when there's enough text scrolling happens. after moving cursor down/scrolling content , moving cursor again, cursor goes behind div content doesn't scroll down. cursor hidden, cannot see content. scrolling via scrollbar works.

do need change html/css fixed div? or need check whether cursor comes behind/under div , have let codemirror scroll manually? tried didn't manage programmatically :-(

<!doctype html> <html> <head>     <meta charset="utf-8">     <link rel=stylesheet href="http://codemirror.net/doc/docs.css">     <link rel=stylesheet href="http://codemirror.net/lib/codemirror.css">     <script src=http://codemirror.net/lib/codemirror.js></script>     <script src=http://codemirror.net/mode/htmlmixed/htmlmixed.js></script>     <style type=text/css>         .codemirror {float: left; width: 100%; height: 100%; }     </style>   </head> <body>   <div style="position: fixed; height: 28px; z-index:999; width: 100%; background: lightgray;">     <button>some action</button>   </div>   <div style="padding-top: 23px">     <textarea id=content name="content"></textarea>   </div>     <script>       var editor = codemirror.fromtextarea(document.getelementbyid('content'), {         mode: 'application/x-httpd-php',         linenumbers: true       });     </script>   </body> </html> 

check out here well: http://jsfiddle.net/fxvef3bw/1/

i found solution on own.

instead of 2 overlapping divs, use 2 divs (non-overlapping), style "position: absolute". don't overlap, scrolling fine.

<!doctype html> <html> <head>     <meta charset="utf-8">     <link rel=stylesheet href="http://codemirror.net/doc/docs.css">     <link rel=stylesheet href="http://codemirror.net/lib/codemirror.css">     <script src=http://codemirror.net/lib/codemirror.js></script>     <script src=http://codemirror.net/mode/htmlmixed/htmlmixed.js></script>     <style type=text/css>         .codemirror {float: left; width: 100%; height: 100%; }     </style>   </head> <body>     <div style="padding: 1px; position: absolute; margin: 0px; top: 0px; bottom: auto; left: 0px; right: 0px; width: auto; height: 24px; background: lightgrey;">         <button>some action</button>     </div>     <div style="padding: 1px; position: absolute; margin: 0px; left: 0px; right: 0px; top: 28px; bottom: 0px; width: auto; height: auto; ">         <textarea id="content" name="content" style="display: none;"></textarea>     </div>     <script>       var editor = codemirror.fromtextarea(document.getelementbyid('content'), {         mode: 'application/x-httpd-php',         linenumbers: true       });     </script>   </body> </html> 

updated jsfiddle here: http://jsfiddle.net/fxvef3bw/2/

i hope can comments possible side effects or drawbacks of position absolute. otherwise seems fine me.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -