减小 TinyMCE 文本区域中的行距
我正在使用 TinyMCE 提供富文本编辑文本编辑器。但行与行之间的行间距太大了。我添加了一个屏幕截图,显示了按 Enter 键时得到的行距。可以做什么
I am using TinyMCE to provide a rich text editing text editor. But the line spacing between the lines is too much. I have added a screenshot that shows the line spacing I get on pressing an enter. What can be done about it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以将自定义 css 添加到 CSS 编辑器,如下所示:
请参阅此处的文档: http:// www.tinymce.com/wiki.php/Configuration:editor_css
然后,您可以将 line-height 属性设置为您希望在该文件中的任何高度。
您还可以更改设置,在生成段落标记 (p) 或换行标记 (br) 之间进行切换,如下所示:
有关详细信息,请参阅此处的文档:http://www.tinymce.com/wiki.php/Configuration:force_br_newlines
我认为 TinyMCE 当你点击时会将段落作为标准输入,这就是为什么你的线条之间有很大的余量。您还可以像在 Word 中一样使用 Shift+Enter 来换行,而不是段落。
You can add custom css to your CSS-editor like this:
See docs here: http://www.tinymce.com/wiki.php/Configuration:editor_css
You can then set a line-height property to whatever height you wish in that file.
You can also change a setting where you can switch between generating paragraph tags (p) or linebreak tags (br) with something like this:
See the docs here for more info: http://www.tinymce.com/wiki.php/Configuration:force_br_newlines
I think TinyMCE does paragraphs as standard when you hit enter, that is why you get a big margin between your lines. You can also use shift+enter like in Word to get a new line that is a line break instead of paragraph.
有一个 css 类应用于 TinyMCE html 内容。看起来您有
标签导致了间距。老实说,它对我来说看起来不错。但您可以在 css 类中进行覆盖:
请参阅 tinymce 文档 了解更多信息。
There is a css class that is applied to the TinyMCE html content. It looks like you have
<p>
tags causing the spacing. Honestly, it looks pretty good to me. But you can override in the css class:See the tinymce docs for more info.
您可以强制 TinyMCE 输出 div 而不是段落。只需将此行放入tinyMCE.init部分:
You can force TinyMCE to output divs instead of paragraphs. Just put this line in your tinyMCE.init section:
我知道,
这篇文章很旧,但可能对某人有帮助。
自 3.5 起,'force_br_newlines' 和 'force_p_newlines' 已弃用。
使用 forced_root_blocks 代替:
I know,
This post is old, but it may help someone.
'force_br_newlines' and 'force_p_newlines' are deprecated as of 3.5.
Use forced_root_blocks instead:
从tinyMCE 4.x 开始,您可以指定此选项
forced_root_block_attrs: { "style": "margin: 5px 0;" }
这将为每个
p
标记附加style: margin: 5px 0;
。PS:它不适用于复制/粘贴内容。
文档:
From tinyMCE 4.x you can specify this option
forced_root_block_attrs: { "style": "margin: 5px 0;" }
this will append
style: margin: 5px 0;
for everyp
tag.P.S: it will not work for copy/paste content.
docs:
如果您有时希望有额外的空间,有时又不想,则保持 TinyMCE 不变。如果您希望段落之间的间距更紧密,而不是按 Enter 键转到下一行,请同时按 Enter 键和 Shift 键。
If you would like sometimes to have the extra space and sometimes not, then leave TinyMCE as is. And when you want the tighter space between paragraphs instead of pressing enter to go to the next line, press enter and shift together.
这是迄今为止我遇到的最好的解决方案......所以你可以使用它:
无论如何......这对我有用
This is the best solution I've encountered so far... so you may use it:
Anyway... that worked for me