How to apply ckeditor css to output -


ck-editor works good, after save editet text ckeditor database, , load page. generated html unformated, there aditional ckeditor js functions have applied target area, or there detault class needed added text container ?

i checked ck-editor css files there no specific class, when check "contents.css" in ckeditor files , there "img.left{border: 1px solid #ccc; .." thats pretty creepy since there no specific class, work in plain iframe if show text ckeditor in more complex page have rewrite css ".wysiwyg img.left" , reset css modified reset.css .wysiwyg class, , pretty hard reset everything, isnt there other way missed badly in ck-editor documentation? since see in there examples in actual editor, not how style generated text itself.

share|improve question
up vote 3 down vote accepted
+100

if want html authored in ckeditor same inside page, first must insert inside div element custom class, example, "my-container".

then have include contents.css in page. here have alternatives: 1) use scoped stylesheets or 2) modify contents.css, scoping each rule.

1. using scoped stylesheets

in case should use scoped stylesheets , jquery scoped css plugin (due current lack of browser support).

your html code this:

<div class="my-container">     <style scoped>         @import "ckeditor/contents.css";     </style>     <!-- html goes here --> </div> 

2. scoping each rule inside contents.css

in case must link modified copy of ckeditor's contents.css file. each of rule's selector must scoped "my-container" class, doesn't affect rest of page. example contents.css file:

.my-container {     /* font */     font-family: sans-serif, arial, verdana, "trebuchet ms";     font-size: 12px;      /* text color */     color: #333;      /* remove background color make transparent */     background-color: #fff;      margin: 20px; }  .my-container .cke_editable {     font-size: 13px;     line-height: 1.6em; }  .my-container blockquote {     font-style: italic;     font-family: georgia, times, "times new roman", serif;     padding: 2px 0;     border-style: solid;     border-color: #ccc;     border-width: 0; }  .my-container .cke_contents_ltr blockquote {     padding-left: 20px;     padding-right: 8px;     border-left-width: 5px; }  .my-container .cke_contents_rtl blockquote {     padding-left: 8px;     padding-right: 20px;     border-right-width: 5px; }  .my-container {     color: #0782c1; }  .my-container ol,.my-container ul,.my-container dl {     /* ie7: reset rtl list margin. (#7334) */     *margin-right: 0px;     /* preserved spaces list items text direction other list.    (#6249,#8049)*/     padding: 0 40px; }  .my-container h1,.my-container h2,.my-container h3,.my-container h4,.my-container h5,.my-container h6 {     font-weight: normal;     line-height: 1.2em; }  .my-container hr {     border: 0px;     border-top: 1px solid #ccc; }  .my-container img.right {     border: 1px solid #ccc;     float: right;     margin-left: 15px;     padding: 5px; }  .my-container img.left {     border: 1px solid #ccc;     float: left;     margin-right: 15px;     padding: 5px; }  .my-container pre {     white-space: pre-wrap; /* css 2.1 */     word-wrap: break-word; /* ie7 */ }  .my-container .marker {     background-color: yellow; }  .my-container span[lang] {    font-style: italic; }  .my-container figure {     text-align: center;     border: solid 1px #ccc;     border-radius: 2px;     background: rgba(0,0,0,0.05);     padding: 10px;     margin: 10px 20px;     display: block; /* ie8 */ }  .my-container figure figcaption {     text-align: center;     display: block; /* ie8 */ } 
share|improve answer
    
i've added config.bodyclass = 'my-container'; config.js , added class my-container document container no luck still same ugly output – youyou sep 18 '14 @ 15:55
    
are linking custom css file page? jsfiddle useful. – ncardeli sep 18 '14 @ 16:13
    
nop need see document entered don't want custom css. – youyou sep 18 '14 @ 16:17
    
but ckeditor loads contents.css file (which can find in main directory), need load same file. can modify (or better copy , save outside ckeditor's directory , edit), selectors there start same class (e.g. my-container). – reinmar sep 19 '14 @ 11:24
    
+1 scoped stylesheets. @jiro should upvote answer too, since you've accepted (unless have reasons not that, guess haven't). – andrea ligios sep 22 '14 @ 12:06

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments