2016-02-10 97 views
3

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

以下是创建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> 

回答

2

您可以通过添加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> 
+1

嘿,它的工作。非常感谢 – ifour

1

我的猜测是,你可以很容易地实现通过使用CSS规则在代码所需的行为下面的片段:

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

+1

嘿,感谢您的答案,但它不是正常的文本区域。它的jHtmlarea和我已经试过这个。不工作。 – ifour

+0

是的,但htmlarea的位置可以通过CSS来调整......代替textarea可以是任何其他元素,如果添加一些html布局将会更加合理。 –

+0

嗨,添加了代码。 – ifour