Jquery 调整默认高度JQTE

Jquery 调整默认高度JQTE,jquery,css,jqte,Jquery,Css,Jqte,如何更改JQTE编辑器的默认高度? 我试过: $("textarea").jqte({ height:"400px" }); 该文档没有对此做任何说明。它们没有提供选项,但您可以这样做: $("textarea").css('min-height','400px').jqte(); 这将自动将高度设置为最小值400px试试这个 $('.jqte_editor').css({ height: '250px' }); 您应该尝试更改jqte样式表中jqte_编辑器的最小高度值: /* edi

如何更改JQTE编辑器的默认高度?
我试过:

$("textarea").jqte({
height:"400px"
});

该文档没有对此做任何说明。

它们没有提供选项,但您可以这样做:

$("textarea").css('min-height','400px').jqte();
这将自动将高度设置为最小值
400px

试试这个

$('.jqte_editor').css({ height: '250px' });

您应该尝试更改jqte样式表中jqte_编辑器的最小高度值:

 /* editor area */
.jqte_editor, .jqte_source {
    min-height:300px;
}

要锁定编辑器的高度,以便显示滚动条而不是编辑器展开,您需要设置
.jqte_editor
高度
最小高度
。您还需要设置
最大高度

接下来发生的是jqte错误:

  • 选择文本并添加粗体/斜体或其他格式
  • 删除格式设置
  • 选定的文本突然继承了
    .jqte_编辑器
    高度值并将下面的每个元素(文本)进一步向下推
修复(jqte版本1.4.0)

打开javascript文件
jquery-te-1.4.0.js

搜索并查找
函数影响样式(元素、样式)

替换:

if(selectedTag && style==false)
{
    // apply to the selected node with parent tag's styles
    if(selectedTag.parent().is("[style]"))
        selectedTag.attr("style",selectedTag.parent().attr("style"));

    // apply to child tags with parent tag's styles
    if(selectedTag.is("[style]"))
        selectedTag.find("*").attr("style",selectedTag.attr("style"));
}
为此:

if(selectedTag && style==false)
{
    // apply to the selected node with parent tag's styles
    if(selectedTag.parent().is("[style]") && !selectedTag.parent().is(".jqte_editor"))
        selectedTag.attr("style",selectedTag.parent().attr("style"));

    // apply to child tags with parent tag's styles
    if(selectedTag.is("[style]") && !selectedTag.parent().is(".jqte_editor"))
        selectedTag.find("*").attr("style",selectedTag.attr("style"));
}
请注意添加的代码:

 && !selectedTag.parent().is(".jqte_editor")

祝你好运

可能太晚了,但我也在寻找一个解决方案,不改变原来的css,因为有些页面我希望它是默认的,有些页面我希望它是自定义大小的。在插件js之后简单设置内联css。像这样的

$('.te_editor').jqte({
});

<style>
.jqte_editor{height:350px;max-height:500px;}
</style>
$('.te_editor').jqte({
});
.jqte_编辑器{高度:350px;最大高度:500px;}

我应用了VKS建议的补丁(稍加修改,请参见我对他的答案的评论)

我使用类似这样的方法来尝试使用原始textarea“rows”属性计算编辑区域的高度(如果没有VKS的补丁,这将导致可怕的问题):


(第25/15行的计算正好适用于我使用“em”s的特殊情况-您需要使用自己的计算,有许多解决方案,例如使用所需字体测量跨度的“px”高度等)

这是解决方案。转到非最小版本以更好地查看此解决方案。我只是添加了少量的代码,以便能够将“height”作为一个启动选项传入,该选项可以完美地插入以控制组件的高度

在版本1.4.0的第215行,添加此修改:

<div class="'+vars.css+"_editor"+'" style="height:'+vars.height+';"></div>
然后将{height:'500px'}传入代码,如下所示:

$(".myCustomTextField").jqte({'height': '500px'});

完成了

如果您想更改特定文本区域的高度,我建议您将文本区域放在一个div中,如下所示

<div class="custom-jqte">
  <textarea id="yourtextarea"></textarea>
</div>

使用此方法,可以避免更改jquery te样式表

如果在样式设置之后包含JQTE CSS,则需要增加选择器的特异性(例如,
body.JQTE_editor,body.JQTE_source
甚至
.JQTE_editor.JQTE_editor,.JQTE_source.JQTE_source
)JS上的选择器错误,它应该是
.jqte_编辑器
,与CSS相同。另外,始终将样式放在文档的标题上,在JavaScript代码之前。我认为第二部分应该是“if(selectedTag.is(“[style]”)和&!selectedTag.is(“.jqte_editor”)”(去掉.parent()位)
$(".myCustomTextField").jqte({'height': '500px'});
<div class="custom-jqte">
  <textarea id="yourtextarea"></textarea>
</div>
.custom-jqte .jqte_editor {
   height: 400px;
}