gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 18:32:15 25 4
gpt4 key购买 nike

你好,这是我的 html 代码。我主要尝试的是:

1-用户在 textaea id="tArea"中粘贴了一些内容

2-当他点击名为“Done”的按钮时,textarea 的内容被分配给具有 id="tDiv"的 div 的内部 html

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>

最佳答案

这是一个基本的 css,div 想要作为一个可调整大小的容器,除非你给它它的尺寸。

这对您有用,删除所有 div 样式并将其添加到样式 block :

我。添加溢出:滚动到 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/

二。使其可调整大小:

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

关于Jquery Mobile Div 的高度不会自动调整(或滚动),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13944159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com