CKEditor & JavaScript - Adjust height and width in CKEditor

淺唱寂寞╮ 提交于 2019-12-09 16:45:43

问题


How can I adjust the height in CKEditor?

Here is my code for CKEditor.

<script type="text/javascript">
    CKEDITOR.replace( 'content',
        {
            toolbar :
            [
                ['Source'],
                ['Bold','Italic','Underline','Strike'],
            ]
        });
</script>

回答1:


Add the height and width setting in the parameters:

CKEDITOR.replace( 'content',
    {
        toolbar :
        [
            ['Source'],
            ['Bold','Italic','Underline','Strike'],
        ],
        height: 300,
        width: 400
    });



回答2:


Go to confi.js file and in the

CKEDITOR.editorConfig = function( config ) {
.
.
.
.
**config.height = 320;**
};

So actually you just need to add config.height = required height;.




回答3:


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(, );

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

That's it!



来源:https://stackoverflow.com/questions/4410939/ckeditor-javascript-adjust-height-and-width-in-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!