CKEditor & JavaScript - 在 CKEditor 中调整高度和宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/4410939/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CKEditor & JavaScript - Adjust height and width in CKEditor
提问by slum
How can I adjust the height in CKEditor?
如何在 CKEditor 中调整高度?
Here is my code for CKEditor.
这是我的 CKEditor 代码。
<script type="text/javascript">
    CKEDITOR.replace( 'content',
        {
            toolbar :
            [
                ['Source'],
                ['Bold','Italic','Underline','Strike'],
            ]
        });
</script>
回答by Fred
Add the height and width setting in the parameters:
在参数中添加高度和宽度设置:
CKEDITOR.replace( 'content',
    {
        toolbar :
        [
            ['Source'],
            ['Bold','Italic','Underline','Strike'],
        ],
        height: 300,
        width: 400
    });
回答by Khandad Niazi
Go to confi.js file and in the
转到 confi.js 文件并在
CKEDITOR.editorConfig = function( config ) {
.
.
.
.
**config.height = 320;**
};
So actually you just need to add   config.height = required height;.
所以实际上你只需要添加   config.height = required height;.
回答by Suhas Manjunath
This can be easily done by adding few lines of code in your common script file.
这可以通过在公共脚本文件中添加几行代码轻松完成。
- Create a member variable to get the total size of paragraph tags var ttl = 0;
 - Check each paragraph element to get it's outer height and append the value back to total $().find('p').each(function() { ttl += $(this).outerHeight(true); });
 - Add the editor header and footer size which was neglected. it's 120px! var total = total+120;
 - Take a reference to your var etr = CKEDITOR.instance[''];
 - Resize your window according to total. etr.resize(, );
 
- 创建一个成员变量来获取段落标签的总大小 var ttl = 0;
 - 检查每个段落元素以获取它的外部高度并将值附加回总 $().find('p').each(function() { ttl += $(this).outerHeight(true); });
 - 添加被忽略的编辑器页眉和页脚大小。它是 120 像素!var 总计 = 总计+120;
 - 参考你的 var etr = CKEDITOR.instance[''];
 - 根据总数调整窗口大小。etr.resize(, );
 
**Note : No need to mention 'px' neither for width nor height. '%' is must!
**注意:宽度和高度都不需要提及“px”。'%' 是必须的!
That's it!
而已!

