Jquery Mobile Div的高度不会自动调整(或滚动)

时间:2012-12-19 01:16:16

标签: jquery html css html5 jquery-mobile

你好,这是我的HTML代码。我基本上尝试的是:

1 - 用户在textaea id =“tArea”

中粘贴一些内容

2 - 当他点击名为“完成”的按钮时,textarea的内容被赋予div的内部html,其id =“tDiv”

3-Div讨论了对其内容应用了不同的字体系列(使用css3并且它完全正常工作),但是当用户的数据变大时, div无法提供滚动条或调整这是自动的高度。

请帮助,我已经消耗了很多时间,但我还是迷路了!

<!DOCTYPE html>
<html>
<head>
<meta name=viewport content="user-scalable=no,width=device-width" />
<link rel=stylesheet href="resources/jquery.mobile.css" />
<script src="resources/jquery.js"></script>
<script src="resources/jquery.mobile.js"></script>
<style>
@font-face {
  font-family: 'Donegal One';
  font-style: normal;
  font-weight: 400;
  src: url(fontfile.ttf) format('truetype');
}
.hindi, textarea {

font-family: 'Donegal One', serif !important;
overflow:auto;
-webkit-overflow-scrolling:touch;
}
</style>
<script>

</script>
</head>
<body>
<div data-role=page id=sendMoneyWin data-add-back-btn=true>
        <div data-role=header data-theme="c" >
            <h1>Font Changer</h1>
        </div>      
        <div data-role=content>
        <script>

            function transformFont(){
                $("#tDiv").html($("#tArea").attr("value"));
                //$("#tArea").css("display","none");
                $("#tArea").prop("readonly",true);
                $("#tDiv").css("display","block");
                $("#doneBtn").css("display","none");
                $("#reloadBtn").css("display","inline");
            }
            function clearAllAndReload(){
                $("#tDiv").html("");
                $("#tArea").attr("value","")
                //$("#tArea").css("display","block");
                //$("#tDiv").css("display","none");
                $("#tArea").prop("readonly",false);
                $("#doneBtn").css("display","inline");
                $("#reloadBtn").css("display","none");
            }
        </script>
        <b>Please paste the contents here, in the below text box :</b><br />
        <span id="reloadBtn" style="display:none;"><input type="button" value=" Reload " onClick="clearAllAndReload()" data-inline=true/></span>
        <span id="doneBtn" ><input type="button" value=" Done " onClick="transformFont()"  data-inline=true /></span>


        <textarea id="tArea" class="hindi" style="" ></textarea>
        <div id="tDiv" class="hindi" data-scroll='true' style="white-space: pre-wrap;overflow:visible;-webkit-overflow-scrolling:touch;display:none;"></div>
        </div>

        <div data-role=footer data-theme="c">
            <span style="float:right;"><small>Created & Maintained by TechBhardwaj, 2012&nbsp;&nbsp;&nbsp;</small></span>
        </div>  
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

这是一个基本的css,div想要表现为一个可重复大小的容器,除非你给它的尺寸。

这将适合您,删除所有div样式并将其添加到样式块:

予。添加溢出:滚动到div并从样式中删除它:

#tDiv {
    /* SCROLL FIX */
    width: 100%;
    height: 200px;   
    overflow:scroll;
    /* END FIX */
    background: #aabbcc;
    white-space:
    pre-wrap;
    -webkit-overflow-scrolling:touch;
    display:none;        
}

这会给你一个滚动条。示例:http://jsfiddle.net/Gajotres/DMqX7/

II。使其可调整大小:

#tDiv {
    /* RESIZE FIX */
    width: 100%;
    height: 200px;   
    min-height: 200px;
    height:auto !important;        
    /* END FIX */
    background: #aabbcc;
    white-space:
    pre-wrap;
    -webkit-overflow-scrolling:touch;
    display:none;        
} 

示例:http://jsfiddle.net/Gajotres/aq8K3/