调整 jHtml 文本区域大小

4

我希望能够像普通文本区域一样调整jHtml文本区域的大小,那么有没有任何方法可以进行调整。

以下是创建jHtml文本区域的代码。

这是HTML代码:

<table style="width: 100%; border-collapse: separate !important; border-spacing: 2px!important">
<tr>
    <td>
        <%=Html.LabelFor(m => m.Description)%>
    </td>
    <td>
        <%=Html.TextAreaFor(m => m.Description, new { @class="form-control",style="width: 610px; height: 150px" })%>
    </td>
</tr>
</table>

以下是 JavaScript 代码:

<script type="text/javascript">
   $(function () {
    $("#Description").htmlarea({
        // Override/Specify the Toolbar buttons to show
        toolbar: [
            ["bold", "italic", "underline", "|", "forecolor"],
             ["p", "h3", "h4", "h5", "h6"],
              ["link", "unlink", "|", "image"],
              ["orderedlist", "unorderedlist"],
              ["increasefontsize", "decreasefontsize"],
              ["indent", "outdent"],
              ["justifyleft", "justifycenter", "justifyright"],
              ["cut", "copy", "paste"]
        ]
    });
});
</script>
2个回答

3
您可以通过添加jHtmlarea的“resizable”属性来实现此行为。希望这能对您有所帮助。
<script type="text/javascript">
   $(function () {
     $("#Description").htmlarea({           
          toolbar: [
             ["bold", "italic", "underline", "|", "forecolor"],
             ["p", "h3", "h4", "h5", "h6"],
             ["link", "unlink", "|", "image"],
             ["orderedlist", "unorderedlist"],
             ["increasefontsize", "decreasefontsize"],
             ["indent", "outdent"],
             ["justifyleft", "justifycenter", "justifyright"],
             ["cut", "copy", "paste"]
         ]
     }).parent().resizable({ alsoResize: $("#comm").find('iframe') });
  });
</script>

1
我猜您可以通过使用以下代码片段中的CSS规则轻松实现所需的行为:

#Comments {
    position:absolute;
    width:60%;
    height:200px;
}
<textarea id="Comments">My text.</textarea>


1
嘿,谢谢你的回答,但这不是普通的文本区域。它是jHtmlarea,我已经尝试过了,但不起作用。 - ifour
是的,但是htmlarea的位置可以通过css进行调整...textarea的位置可以替换为任何其他元素,如果添加一些html布局会更好。 - Andriy Ivaneyko

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接