如何设置tinymce文本区域的高度?

5 html css tinymce

我使用以下内容:

    <textarea
    data-ui-tinymce="tinymceOptions"
    data-ng-disabled="modal.action=='delete'"
    data-ng-model="modal.formData.text"
    id="inputText"
    rows="20"
    required></textarea>
Run Code Online (Sandbox Code Playgroud)

当tinymce出现时,高度只有几厘米.如何在首次出现时更改默认值的高度?

以下是我使用的选项列表:

selector: "textarea",           
plugins: [
                        "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
                        "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                        "table contextmenu template textcolor paste fullpage textcolor"
                ],

                toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect fontselect fontsizeselect",
                toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | code | inserttime preview | forecolor backcolor",
                toolbar3: "table | hr removeformat | subscript superscript | charmap | print fullscreen | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft",

                menubar: false,
                toolbar_items_size: 'small',

                templates: [
                        {title: 'Test template 1', content: 'Test 1'},
                        {title: 'Test template 2', content: 'Test 2'}
Run Code Online (Sandbox Code Playgroud)

]

Sol*_*uiD 17

来自javascript

tinymce.init({
   selector: 'textarea',
   height: 200
});
Run Code Online (Sandbox Code Playgroud)

或者来自html

<textarea style="height: 200px;">
Run Code Online (Sandbox Code Playgroud)

  • 这应该是正确的答案,这解决了丹·罗宾逊(Dan Robinson)提到的对当前所选答案的评论 (2认同)

Dav*_*shi 6

你应该在CSS中设置容器对象的高度:

#inputText {
    height : 10000000px;
}
Run Code Online (Sandbox Code Playgroud)

  • 明智的话:如果在运行tinyMCE初始化脚本时隐藏textarea,这将无效.(通过"隐藏",我的意思是textarea或其中一个祖先设置为"display:none.")初始化时,tinyMCE测量屏幕上textarea的高度,然后用iframe替换它,并给iframe高度相同通过内联样式("高度:300px").例如,如果您的textarea位于初始化编辑器时设置为"display:none"的模态窗口内,tinyMCE将测量textarea的高度为零,并且不会为iframe指定内联高度. (3认同)