javascript 调整响应式设计的ckeditor
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21207312/
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
resize ckeditor for responsive design
提问by user2250471
I'm trying to use CKEditor on a responsive design, and I cannot get the height to work. The following code with height define works to resize the text area to 100%, which overflows the containing div.
我正在尝试在响应式设计上使用 CKEditor,但我无法让高度起作用。以下具有高度定义的代码用于将文本区域的大小调整为 100%,这会溢出包含的 div。
CKEDITOR.replace( 'article', {
toolbar: [
{ name: 'basicstyles', items: [ 'Bold', 'Italic' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Blockquote' ] },
{ name: 'links', items : [ 'Link','Unlink' ] },
{ name: 'insert', items : [ 'Image' ] }
],
uiColor: '#f9fafb',
height: '100%'
});
I have found the below code, but I can't figure out where to paste it. I've also tried editing config.js, and following all the documentation on CKEDitor's website. They tell you what to do, but not where to do it.
我找到了下面的代码,但我不知道在哪里粘贴它。我还尝试编辑 config.js,并遵循 CKEDitor 网站上的所有文档。他们会告诉你该做什么,但不会告诉你在哪里做。
editor.resize( '100%', '350', true );
In theory, the "true" will make the height include the entire editor, not just the text area, but I don't know where it belongs.
理论上,“true”会使高度包括整个编辑器,而不仅仅是文本区域,但我不知道它属于哪里。
The div containing the editor uses this CSS:
包含编辑器的 div 使用此 CSS:
height: -moz-calc(100% - 400px);
height: -webkit-calc(100% - 400px);
height: calc(100% - 400px);
回答by sandeep
if u want to do responsive need to change setting in config.js
如果你想做响应式需要改变设置 config.js
CKEDITOR.editorConfig = function (config) {
config.width = "auto";
config.height = "auto";
回答by Mohammed
In django, I had to set the width to auto
in the settings.py
file:
在 Django 中,我必须auto
在settings.py
文件中设置宽度:
CKEDITOR_CONFIGS = {
'default': {
'toolbar': None, #You can change this based on your requirements.
'width': 'auto',
},
}
回答by GabLeRoux
Find which div has a fixed width and force it's width to auto
.
查找哪个 div 具有固定宽度并强制其宽度为auto
。
#cke_description {
width: auto !important;
}
Worked for me on Version 4.4.4
.
对我来说有效Version 4.4.4
。