user1257239
user1257239

Reputation:

How to resize CKEditor to fit its parent div

I have a CKeditor which is placed in a parent div. What is the best way to have the CKEditor exactly fit the div and resize when the div resizes? If possible I would prefer solutions which don't involve jQuery. If this is not possible solutions using jQuery would be fine to.

Upvotes: 7

Views: 7662

Answers (3)

Sunny
Sunny

Reputation: 112

If someone needs this now, I added this to my css file:

#cke_id_text {
  width: fit-content!important;
}

Upvotes: 0

rmmoul
rmmoul

Reputation: 3217

Use the width attribute when you call ckeditor.

<script type="text/javascript">
//<![CDATA[

CKEDITOR.replace( 'page_content',
{
    toolbar : 'MyToolbar',
    width : '100%'


});

//]]>
</script>

Since the call to initialize the editor is done with jquery, this is the best way.

edit: This will cause ckeditor to auto-resize when the div width changes as well.

Upvotes: 1

semir.babajic
semir.babajic

Reputation: 741

var editor = CKEDITOR.replace( 'editor' );

...

And then, in event of your choice, do this:

editor.resize($("#elem").width(),$("#elem").height());

Hope this helped.

Upvotes: 6

Related Questions