如何将CSS类设置为ckeditor的div区域

风13

我正在使用ckeditor和divarea插件,以便可以在div中(而不是在iframe中)使用ckeditor。

因此,ckeditor可以继承页面的css样式。

现在,我要设置ckeditor内容的样式。

一种解决方案是这样的:

.cke_contents h1 {
    font-size: 32px;
    /* custom styles */
}
.cke_contents p {
    font-size: 12px;
    /* custom styles */
}

恐怕这可能会引起其他问题。因此,我的想法是设置一个类名,以便可以自由设置自定义样式。像这样:

<textarea id="ckeTextblock"></textarea>

<script>
    CKEDITOR.replace("ckeTextblock", {
    extraPlugins: 'divarea',
    bodyClass: 'customClassName'
})
</script>

.customClassName h1 {
    font-size: 32px;
    /* custom styles */
}
.customClassName p {
    font-size: 12px;
    /* custom styles */
}

我已经尝试过“ bodyClass”配置,但是在divarea中不起作用。

有人有主意吗?谢谢!

风13

最后,由于使用了divarea,因此ckeditor继承了页面的CSS,因此我在页面的scss中使用了如下的CSS覆盖:

#cke_richTextArea .cke_wysiwyg_div {
   padding: 15px;
   h1 {
       // custom it.
   }
   p {
       // custom it.
   }
}

关于ckeditor“格式”下拉菜单样式(如h1,p等)的另一件事,我可以复制和自定义新皮肤并修改editor.css和editor _ *。css。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章