簡體   English   中英

CKEditor和JavaScript - 在CKEditor中調整高度和寬度

[英]CKEditor & JavaScript - Adjust height and width in CKEditor

如何在CKEditor中調整高度?

這是我的CKEditor代碼。

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

在參數中添加高度和寬度設置:

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

轉到confi.js文件並在

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

所以實際上你只需要添加config.height = required height;

這可以通過在公共腳本文件中添加幾行代碼輕松完成。

  1. 創建一個成員變量來獲得段落標簽的總大小var ttl = 0;
  2. 檢查每個段落元素以獲得它的外部高度並將值追加到總$()。find('p')。each(function(){ttl + = $(this).outerHeight(true);});
  3. 添加被忽略的編輯器頁眉和頁腳大小。 這是120px! var total =總數+ 120;
  4. 參考你的var etr = CKEDITOR.instance [''];
  5. 根據總數調整窗口大小。 etr.resize(,);

**注意:無論是寬度還是高度,都不需要提及'px'。 '%'是必須的!

而已!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM