Search code examples
cssckeditorwysiwygrich-text-editor

CKEditor set textarea margin dynamically


I'm having a trouble in CKEditor for setting margin in each template dynamic. right now what i'm doing is hitting directly into content.css

my question is how to set margin directly from php modul.

this is my content.css that I'm direct hit

body
{
    /* Font */
    font-family: sans-serif, Arial, Verdana, "Trebuchet MS";
    font-size: 12px;

    /* Text color */
    color: #333;

    /* Remove the background color to make it transparent */
    background-color: #fff;

    /*margin: 113px 94px 151px 113px; */
    margin: 3cm 2.5cm 4cm 3cm;
}

Thanks, Hendra


Solution

  • Make a div outside your ckeditor textarea/div and give margin to outside div.

    <div id = "ckeContainer">
        <textarea name="editor1">This textarea is used for CKeditor</textarea>
    </div>
    
    <script>
        document.getElementById('ckeContainer').style.margin="3px 2px 3px 4px";
    </script>
    

    EDIT

    You Can also try below Javascript:

    document.body.style.margin = "3px 2px 3px 4px";
    

    Hope it helps!