Hello here is my html code. What I am basically trying is:
1-User pastes some contents inside textaea id=”tArea”
2-When he clicks on a button named “Done”, the contents of textarea are asigned to div’s inner html having id=”tDiv”
3-The Div discussed applied a different font family to the contents of it (using css3 and it’s perfectly working), but when the user’s data get large, the div is not able to either provide a scrollbar or adjust it’s height automatically.
Please Help, I have consumed many many hours but I’m still lost!
<!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 </small></span>
</div>
</div>
</body>
</html>
This is a basic css, div want behave as a re-sizable container unless you give it its dimensions.
This will work for you, remove all div styles and add it to a style block:
I. Add an overflow: scroll to div and remove it from style:
This will give you a scrollbar. Example: http://jsfiddle.net/Gajotres/DMqX7/
II. Make it resizable:
Example: http://jsfiddle.net/Gajotres/aq8K3/