现在我正在使用Summernote文本编辑器。有没有办法以百分比设置其宽度和高度?不幸的是,我找不到任何答案。
editor.summernote({
//buttons in toolbar
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontname', 'fontsize', 'style']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['customButton', ['equation']],
['util', ['undo', 'redo']],
],
// prevents copying of text formattion from an external resource
callbacks: {
onPaste: function (e) {
var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
e.preventDefault();
document.execCommand('insertText', false, bufferText);
}
},
buttons: {
equation: equationButton
},
toolbarContainer: '#editorToolbar',
placeholder: 'Type Here',
height: 200,
width: 200, // - > **something like 40% ?**
});
谢谢你的回答!
你可以在.note-editor
类上通过CSS设置宽度,如果你需要同时做宽度和高度百分比,那么CSS只会不切割它然后你可以通过CSS和高度设置宽度,如下所示:
$('.note-editor').height($(window).height()* 0.4)); sets it to 40% of screen height.