如何在summernote中设置字体大小

如何在summernote中设置字体大小

本文介绍了如何在summernote中设置字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用summernote作为默认的文本编辑器,但初始化时默认无法设置特定的字体大小.

到目前为止,我已经尝试过

  $('.active-textcontainer').summernote({工具栏:[['style',['bold','italic','underline']],['fontsize',['fontsize']],['color',['color']],['para',['ul','ol','paragraph']]],高度:150,fontsize:'18px'}); 

  $('.active-textcontainer').summernote({工具栏:[['style',['bold','italic','underline']],['fontsize',['fontsize']],['color',['color']],['para',['ul','ol','paragraph']]],高度:150,fontsize:'18'}); 

蚂蚁的帮助将不胜感激.

解决方案

我从不使用 summernote ,但是请查看 API 没有(至少现在)没有指定默认字体大小,我进行了一次测试,就像您一样,似乎没有人可以使用.

对此的可能解决方案是使用 jQuery font-size 样式直接应用于编辑器 div ,因为在初始化对象中的> summernote 始终创建以下 div :< div class ="note-editable" ...> ...</div> .因此,您可以在初始化 $('.note-editable').css('font-size','18px'); 后执行以下操作:

  $('.active-textcontainer').summernote({工具栏:[['style',['bold','italic','underline']],['fontsize',['fontsize']],['color',['color']],['para',['ul','ol','paragraph']]],高度:150});$('.note-editable').css('font-size','18px'); 

此解决方案有点棘手,如果 div 编辑器的 class 名称在下一个版本中更改,将无法正常工作,但是也许足以满足您的情况./p>

希望这会有所帮助,

I have been using summernote as my default text editor but I haven't been able to set a particular font-size by default when i initialize it.

so far I have tried

$('.active-textcontainer').summernote({
        toolbar: [
            ['style', ['bold', 'italic', 'underline']],
            ['fontsize', ['fontsize']],
            ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']]
        ],
         height:150,
         fontsize:'18px'
    });

and

$('.active-textcontainer').summernote({
        toolbar: [
            ['style', ['bold', 'italic', 'underline']],
            ['fontsize', ['fontsize']],
            ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']]
        ],
         height:150,
         fontsize:'18'
    });

Ant help will be appreciated.

解决方案

I've never use summernote, however looking at the API there is nothing (at least now) to specify default font size, I make a test doing some tries like you and seems that no one works.

A possible solution to this is to apply directly the font-size style to the editor div using jQuery because when you initialize summernote in an object always create the follow div : <div class="note-editable" ...>...</div>. So you can do the follow after initialization $('.note-editable').css('font-size','18px'); in your code this could be:

$('.active-textcontainer').summernote({
    toolbar: [
        ['style', ['bold', 'italic', 'underline']],
        ['fontsize', ['fontsize']],
        ['color', ['color']],
        ['para', ['ul', 'ol', 'paragraph']]
    ],
     height:150
});

$('.note-editable').css('font-size','18px');

This solution it's a little tricky an if the class name of the div editor change on the next version this will not work however maybe it's enough for your case.

Hope this helps,

这篇关于如何在summernote中设置字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 18:00