Apply Twitter Bootstrap stylings to CodeMirror?
Code Mirror and Bootstrap (v3 and v4):
Styling does not yet support validation states (has-error, has-warning, has-success)
.CodeMirror {
/* Bootstrap Settings */
box-sizing: border-box;
margin: 0;
font: inherit;
overflow: auto;
font-family: inherit;
display: block;
width: 100%;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); /* Bootstrap 3 */
box-shadow: none; /* Bootstrap 4 */
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
/* Code Mirror Settings */
font-family: monospace;
position: relative;
overflow: hidden;
}
.CodeMirror-focused {
/* Bootstrap Settings */
border-color: #66afe9;
outline: 0;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6); /* Bootstrap 3 */
box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25); /* Bootstrap 4 */
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
CodeMirror hides the original textarea
and creates a (fairly complex) structure of div
and pre
elements. You can style the outermost div
which has a class of .CodeMirror
to achieve the same effect.
This will require customizing the CodeMirror stylesheet or adding your own style for the class/element. If you are building Bootstrap using LESS, there may be a way to apply a mixin to avoid duplicating the textarea
style, though the amount of duplication is probably minimal.