如何在查询移动设备中调整文本区域的大小?

时间:2013-07-19 08:06:59

标签: jquery-mobile

你能告诉我如何调整文本区域的大小吗?实际上问题是我在按钮点击时打开弹出屏幕。在我的弹出屏幕中,我有一个文本区域(面积很小)。

<textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>

我在该文本区域写了很多字符而不是关闭它。我再次打开它,它与关闭前的面积相同(大面积)?如何调整该文本区域的大小,使其以相同的起始大小开始。

我的代码:

<div data-role="popup" id="CaseInformationScreen" data-close-btn="none" data-overlay-theme="a" data-dismissible="false">
    <div data-role="header" data-theme="b"> <a href="#" data-role="button" data-corners="false" id="Cancel">Cancel</a>
         <h1>Case Information</h1>
         <a href="#" data-role="button" data-corners="false" id="AddButton">Add</a>
    </div>
    <div data-role="content">
        <div>
            <img src="img/Documents.png" />
        </div>
        <div data-role="fieldcontain">
            <label for="text-12" style="text-align:top;margin-left: 0px;">Case Name:</label>
            <input name="text-12" id="text-12" value="" type="text" class="caseName_h" autocorrect="off">
        </div>
        <div data-role="fieldcontain">
            <label for="caseDate" style="text-align:left;margin-left: 0px;">Case Date:</label>
            <input name="caseDate" id="caseDate" value="" type="date" class="caseDate_h">
            <!--input name="mydate2" id="mydate2" type="date" data-role="datebox" class="caseDate_h" data-options='{"mode": "calbox","useNewStyle":true,"zindex":1200}'/-->
        </div>
        <div data-role="fieldcontain">
            <label for="textarea-12">Case Notes :</label>
            <textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:2)

工作示例:http://jsfiddle.net/Gajotres/7JqRG/3/

只需使用此CSS:

#text-12 {
    width: 100% !important;
    height: 50px !important;
    max-height: 50px !important;
}

它会锁定textarea的高度。 !important必须用于覆盖默认值。

答案 1 :(得分:0)

$('#text-12').css('width','whatyouwant');

$('#text-12').attr('cols','whatyouwant'); //for the width
$('#text-12').attr('rows','whatyouwant'); //for the height