"editor"
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html lang='en' class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/mohdule/pen/WpQbjx?limit=all&page=60&q=editor" /> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css'> <style class="cp-pen-styles">body { min-height: 100vh; background: -webkit-linear-gradient(300deg, #de7aff, #62a9b9); background: linear-gradient(150deg, #de7aff, #62a9b9); display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: column wrap; flex-flow: column wrap; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; font-family: "Open Sans", sans-serif; } body h1, body h2 { color: #1a1930; margin: 0.3rem; } .editor { margin-top: 2rem; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: row wrap; flex-flow: row wrap; min-width: 60vw; min-height: 70vh; background: grey; box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5); } .editor .gutter { background: #11101f; color: grey; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: column wrap; flex-flow: column wrap; padding: 1rem; } .editor .gutter span { padding: 0.5rem; color: #62a9b9; } .editor textarea { background: #1a1930; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; border: 0; color: white; padding: 1rem; line-height: 2; } .editor textarea:focus { outline: none; } </style></head><body> <h1>Gutter Line Numbers Experiment</h1> <div class="editor"> <div class="gutter"><span>1</span></div> <textarea rows="5"></textarea> </div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script> <script >var input = document.querySelector('textarea'); var gutter = document.querySelector('.gutter'); var val = input.value; var i = 1; input.addEventListener('input', update); function update() { val = input.value; var lineBreaks = val.match(/\n/g); // alert('Hi'); var numOfSpans = gutter.childElementCount; var numOfLines = lineBreaks.length + 1; if (numOfSpans < numOfLines) { var el = document.createElement('span'); el.innerHTML = numOfLines; gutter.appendChild(el); } else if (numOfSpans > numOfLines){ gutter.removeChild(gutter.childNodes[numOfLines]); } } update(); // Darn !! i can't get rid of the second span >_< //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: