简体   繁体   English

如何在 CKEditor 4 中设置默认字体?

[英]How to set default font in CKEditor 4?

I want to set default font family "Arial" in the CKeditor 4. The below changes have been done.我想在 CKeditor 4 中设置默认字体系列“Arial”。以下更改已完成。 But not working.但不工作。

In config.js,在 config.js 中,

config.defaultFontLabel = "Arial";

You can create your own css files and put the styles for the editor in there.您可以创建自己的 css 文件并将编辑器的样式放入其中。 So create a stylesheet called MyStyle.css and put this in there.因此,创建一个名为MyStyle.css的样式表并将其放入其中。 Then save it somewhere, perhaps in the same location as the CKEditor files.然后将其保存在某处,可能与 CKEditor 文件位于同一位置。

body {
    font-family: Arial;
    font-size: 14px;
    color: red;
}

Then put the following line in the config.js and point to the correct path to the css file.然后在config.js以下行并指向 css 文件的正确路径。

config.contentsCss = '/ckeditor/MyStyle.css';

Or if you want different styles per instance, use this或者,如果您想要每个实例不同的样式,请使用此

<textarea id="CKEditor1" class="CKEditor"></textarea>

<script src="/ckeditor/ckeditor.js"></script>
<script>
    $('.CKEditor').each(function () {
        CKEDITOR.replace($(this).prop('id'));

        CKEDITOR.config.contentsCss = '/ckeditor/MyStyle.css';
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM