【问题标题】:Resize jHtml text area调整 Html 文本区域的大小
【发布时间】:2016-02-10 10:18:56
【问题描述】:

我想像普通文本区域一样调整 jHtml TextArea 的大小,有什么方法可以调整大小。

以下是创建jHtml Textarea的代码。

这是 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>

【问题讨论】:

    标签: javascript jquery wysiwyg jhtmlarea


    【解决方案1】:

    您可以通过添加 jHtmlarea 的“可调整大小”属性来实现该行为。希望能帮到你。

    <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>
    

    【讨论】:

      【解决方案2】:

      我的猜测是,您可以通过使用 css 规则轻松实现所需的行为,如下面的代码 sn-p 所示:

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

      【讨论】:

      • 嘿,谢谢你的回答,但它不是正常的文本区域。它的 jHtmlarea 我已经尝试过这个。不工作。
      • 是的,但是htmlarea的位置可以通过css调整...代替textarea可以是任何其他元素,如果添加一些html布局会更好..
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-29
      相关资源
      最近更新 更多