ckeditor - 带cdn的行距
问题描述
如果我使用 CDN,如何设置 ckeditor 的单行间距?
我看到了几个插件来解决这个问题,但我只想使用 cdn 并在按下回车键时将其保留为单个空格。
提前致谢
解决方案
ckeditor 不会添加额外的行距,它只是为每个编写的段落添加 ap 标签,当您按下 ENTER 时,会为您编写的下一个段落创建一个新的 p 段落标签。
您看到的可能是margin-bottom: 25px;
默认应用于段落的 CSS 规则。要减少此边距,只需使用如下规则创建一个 CSS 文件:
body.article-editor p {
margin-bottom: 10px;
}
即使您只是导入 CDN,我假设您正在代码中某个<script>
标记内的某处初始化 ckeditor。在这段 JavaScript 代码中,设置 CKEDITOR 配置 contentsCss 如下:
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 最新版本。
推荐阅读
- javascript - 我可以引用与我当前在 JavaScript 中使用的窗口不同的窗口吗?
- arrays - 如何将表单输入保存到 json 数据中并保存到 1 个字段表中
- python - Bigquery:如果不存在则创建表并使用 Python 和 Apache AirFlow 加载数据
- git - “Makefile:17146: *** 多个目标模式。停止。” 在安装 grpc 时
- shell - 我可以在多个域中使用 GAM 吗?
- java - 我在助手应用程序上编程 java 时遇到问题
- listview - 如何将条目的数据传递给列表视图?
- java - 扩展 JLabel 的类不遵循容器的布局
- regex - 如何为将触发 Angular 形式的模式错误的域验证编写正则表达式
- amazon-web-services - 如何从不同账户中的 VPC 从 Lambda 访问 Redshift