CodeMirror:如何在编辑器中限制高度 [英] CodeMirror : how to limit height in editor
本文介绍了CodeMirror:如何在编辑器中限制高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用。
I am using codemirror to show some code on a webpage. But when I initialize the codemirror editor, the height of the editor is way more than the number of lines in the code. Please see this fiddle or below image to understand what I am saying Below is the code to create the codemirror editor.
var myCodeArea = document.getElementById("codeArea");
var myCodeMirror = CodeMirror(function(elt) {
myCodeArea.parentNode.replaceChild(elt, myCodeArea);
}, {value: myCodeArea.innerHTML,
lineNumbers:true, mode:"javascript"});
I read codemirror doc but not able to figure out which property controls the height.
Please help me with this
解决方案
The height can be set through CSS (by giving the .CodeMirror
class a height
property), or by calling the editor's setSize
method.
If you want the editor height to correspond to the height of it's contents, see this demo.
这篇关于CodeMirror:如何在编辑器中限制高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文