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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 11:20:24  来源:igfitidea点击:

CKEditor & JavaScript - Adjust height and width in CKEditor

javascriptckeditor

提问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.

这可以通过在公共脚本文件中添加几行代码轻松完成。

  1. Create a member variable to get the total size of paragraph tags var ttl = 0;
  2. 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); });
  3. Add the editor header and footer size which was neglected. it's 120px! var total = total+120;
  4. Take a reference to your var etr = CKEDITOR.instance[''];
  5. Resize your window according to total. etr.resize(, );
  1. 创建一个成员变量来获取段落标签的总大小 var ttl = 0;
  2. 检查每个段落元素以获取它的外部高度并将值附加回总 $().find('p').each(function() { ttl += $(this).outerHeight(true); });
  3. 添加被忽略的编辑器页眉和页脚大小。它是 120 像素!var 总计 = 总计+120;
  4. 参考你的 var etr = CKEDITOR.instance[''];
  5. 根据总数调整窗口大小。etr.resize(, );

**Note : No need to mention 'px' neither for width nor height. '%' is must!

**注意:宽度和高度都不需要提及“px”。'%' 是必须的!

That's it!

而已!