带cdn的行距
line spacing with cdn
如果使用cdn,如何设置单行间距的ckeditor?
我看到有几个插件可以解决这个问题,但我只想使用 cdn 并在按下回车键时将其设置为单个 space。
提前致谢
Ckeditor 不会添加额外的行间距,它只是为每个编写的段落添加一个 p 标签,当您按 ENTER 键时,将为您编写的下一个段落创建一个新的 p 段落标签。
您看到的可能是默认应用于段落的 margin-bottom: 25px;
CSS 规则。要减少此边距,只需使用如下规则创建一个 CSS 文件:
body.article-editor p {
margin-bottom: 10px;
}
即使您只是导入 CDN,我也假设您是在 <script>
标记内的代码中某处初始化 ckeditor。在这段JavaScript代码中,设置CKEDITOR配置内容Css如下:
CKEDITOR.config.contentsCss = '/css/mysitestyles.css';
有关其工作原理的更多信息,请查看有关 contentsCss 配置的文档 属性:
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-contentsCss
反馈后编辑:
感谢您分享您的代码。我已经更正了你的HTML,因为你有一些小的HTML错误:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor</title>
<script src="https://cdn.ckeditor.com/4.12.1/standard/ckeditor.js"></script>
</head>
<body>
<textarea name="editor1"></textarea>
<script>
CKEDITOR.config.contentsCss = 'mystyles.css';
CKEDITOR.replace( 'editor1' );
</script>
</body>
</html>
此外,由于您在文本编辑模式而不是文章编辑模式下使用 Ckeditor,请改用此 CSS:
.cke_editable p {
margin-top: 0px;
margin-bottom: 0px;
}
这适用于最新版本的 Firefox。
如果使用cdn,如何设置单行间距的ckeditor?
我看到有几个插件可以解决这个问题,但我只想使用 cdn 并在按下回车键时将其设置为单个 space。
提前致谢
Ckeditor 不会添加额外的行间距,它只是为每个编写的段落添加一个 p 标签,当您按 ENTER 键时,将为您编写的下一个段落创建一个新的 p 段落标签。
您看到的可能是默认应用于段落的 margin-bottom: 25px;
CSS 规则。要减少此边距,只需使用如下规则创建一个 CSS 文件:
body.article-editor p {
margin-bottom: 10px;
}
即使您只是导入 CDN,我也假设您是在 <script>
标记内的代码中某处初始化 ckeditor。在这段JavaScript代码中,设置CKEDITOR配置内容Css如下:
CKEDITOR.config.contentsCss = '/css/mysitestyles.css';
有关其工作原理的更多信息,请查看有关 contentsCss 配置的文档 属性: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-contentsCss
反馈后编辑:
感谢您分享您的代码。我已经更正了你的HTML,因为你有一些小的HTML错误:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor</title>
<script src="https://cdn.ckeditor.com/4.12.1/standard/ckeditor.js"></script>
</head>
<body>
<textarea name="editor1"></textarea>
<script>
CKEDITOR.config.contentsCss = 'mystyles.css';
CKEDITOR.replace( 'editor1' );
</script>
</body>
</html>
此外,由于您在文本编辑模式而不是文章编辑模式下使用 Ckeditor,请改用此 CSS:
.cke_editable p {
margin-top: 0px;
margin-bottom: 0px;
}
这适用于最新版本的 Firefox。