Here is a jquery to auto resize text according to #outer
div width and height okay. If i change #outer
div width and height manually before render HTML then its fitting text (auto resizing text) properly to #outer
div. Just Like see in Example 1 and Example 2 its fitting text.
Example-1
$.fn.fitInText = function() {
this.each(function() {
let textbox = $(this);
let textboxNode = this;
let mutationCallback = function(mutationsList, observer) {
if (observer) {
observer.disconnect();
}
textbox.css('font-size', 0);
let desiredHeight = textbox.css('height');
for (i = 12; i < 50; i++) {
textbox.css('font-size', i);
if (textbox.css('height') > desiredHeight) {
textbox.css('font-size', i - 1);
break;
}
}
var config = {
attributes: true,
childList: true,
subtree: true,
characterData: true
};
let newobserver = new MutationObserver(mutationCallback);
newobserver.observe(textboxNode, config);
};
mutationCallback();
});
}
$('#inner').fitInText();
#outer {
display: table;
width: 500px;
height: 300px;
transition: width 1s;
}
#inner {
border: 1px solid black;
height: 170px;
text-align: center;
display: table-cell;
vertical-align: middle;
word-break: break-all;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="outer">
<div id="inner" contenteditable=true>
We think the Spirit working through the Word, not an expert at the head of the classroom, is essential to discipleship. When we begin here we learn “how to think biblically”. Our focus is less on answering questions you don’t have and more on helping you learn how to find the answers within thes is less on answering questions you don’t have and mos is less on answering questions you don’t have and more on helping you learn how to find the answers within the Bible. We must seek Jesus in the Bible, trusting that God has the answers. This means learning patichurch leadership, but we are available to supply coaches to be to answer questions or suggest next areas to study based on their questions.
</div>
</div>
Example-2 with increased #outer
div width and height, its still working to fit text into #outer
$.fn.fitInText = function() {
this.each(function() {
let textbox = $(this);
let textboxNode = this;
let mutationCallback = function(mutationsList, observer) {
if (observer) {
observer.disconnect();
}
textbox.css('font-size', 0);
let desiredHeight = textbox.css('height');
for (i = 12; i < 50; i++) {
textbox.css('font-size', i);
if (textbox.css('height') > desiredHeight) {
textbox.css('font-size', i - 1);
break;
}
}
var config = {
attributes: true,
childList: true,
subtree: true,
characterData: true
};
let newobserver = new MutationObserver(mutationCallback);
newobserver.observe(textboxNode, config);
};
mutationCallback();
});
}
$('#inner').fitInText();
#outer {
display: table;
width: 700px;
height: 400px;
transition: width 1s;
}
#inner {
border: 1px solid black;
height: 170px;
text-align: center;
display: table-cell;
vertical-align: middle;
word-break: break-all;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="outer">
<div id="inner" contenteditable=true>
We think the Spirit working through the Word, not an expert at the head of the classroom, is essential to discipleship. When we begin here we learn “how to think biblically”. Our focus is less on answering questions you don’t have and more on helping you learn how to find the answers within thes is less on answering questions you don’t have and mos is less on answering questions you don’t have and more on helping you learn how to find the answers within the Bible. We must seek Jesus in the Bible, trusting that God has the answers. This means learning patichurch leadership, but we are available to supply coaches to be to answer questions or suggest next areas to study based on their questions.
</div>
</div>
But if i change #outer
div width and height ratio from Jquery onclick
button then its not changing text font size again and not fitting text to div.
means i want making change #outer
div width and height through button
then it should be working Like see Example 3, Although i added onclick="fitInText()"
to button. . i want to make work it with example 3 situation.
After click on button just add any letter, space in
#outer
div content and see magic.
$.fn.fitInText = function() {
this.each(function() {
let textbox = $(this);
let textboxNode = this;
let mutationCallback = function(mutationsList, observer) {
if (observer) {
observer.disconnect();
}
textbox.css('font-size', 0);
let desiredHeight = textbox.css('height');
for (i = 12; i < 50; i++) {
textbox.css('font-size', i);
if (textbox.css('height') > desiredHeight) {
textbox.css('font-size', i - 1);
break;
}
}
var config = {
attributes: true,
childList: true,
subtree: true,
characterData: true
};
let newobserver = new MutationObserver(mutationCallback);
newobserver.observe(textboxNode, config);
};
mutationCallback();
});
}
$('#inner').fitInText();
//Jquery for change outer div width
$('.newsize').on('click', function() {
$('#outer').toggleClass('newouter');
});
#outer {
display: table;
width: 500px;
height: 300px;
transition: width 1s;
}
#outer.newouter {
display: table;
width: 700px;
height: 400px;
}
#inner {
border: 1px solid black;
height: 170px;
text-align: center;
display: table-cell;
vertical-align: middle;
word-break: break-all;
}
<script src="code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="newsize" onclick="fitInText()"> Change Width Height </button>
<div id="outer">
<div id="inner" contenteditable=true>
We think the Spirit working through the Word, not an expert at the head of the classroom, is essential to discipleship. When we begin here we learn “how to think biblically”. Our focus is less on answering questions you don’t have and more on helping you learn how to find the answers within thes is less on answering questions you don’t have and mos is less on answering questions you don’t have and more on helping you learn how to find the answers within the Bible. We must seek Jesus in the Bible, trusting that God has the answers. This means learning patichurch leadership, but we are available to supply coaches to be to answer questions or suggest next areas to study based on their questions.
</div>
</div>
provigil generic – provigil settlement provigil dosage
accutane generic – purchase accutane with paypal accutane 40mg
amoxicillin without a doctor’s prescription – bulk order amoxicillin in usa amoxicillin
free vardenafil – site buy vardenafil online cheap
ivermectin pills for humans – buy ivermectin uk ivermectin lotion price
over the counter tadalafil – discount pharmacy cialis purchase online australia
buy ivermectin 2mg – stromectol ireland
accutane purchase uk – accutane isotretinoin 30 mg
lyrica tablets 50mg – lyrica 300 mg price in india buying drugs from canada
amoxicillin price – walmart amoxicillin price amoxicillin without a doctors prescription
viagra 100mg online uk – where can i buy cheap viagra online viagra tablets for sale uk
tadalafil tablets uk – cialis from mexico how to buy cialis from canada
stromectol online canada – ivermectin human how much is ivermectin
deltasone without script online in mexico – prednisone for sale without a prescription prednisone 54
order provigil – provigil 100mg buy provigil online
can you buy zithromax online – buy azithromycin 100mg online buy generic azithromycin 100mg
lasix tablets 20 mg – furosemide 40 mg tablet buy furosemide 160 mg
clomid dose – site where can i buy clomid
cheap canadian pharmacy cialis – cialis 5mg price cost of cialis without insurance
stromectol 15 mg – cost of ivermectin 1% cream buy stromectol pills
free slots – ocean casino online free slots online
fda approved over the counter ed pills – herbal ed pills what is the best ed pill
online prednisone 5mg – prednisonepll buy generic prednisone online
buy discount viagra online – buy cheap viagra usa viagra 50mg
onlinecanadianpharmacy 24 – Cialis next day cialis generic pharmacy
ivermectin 12mg – ivermectin for sale stromectol ivermectin
erectile dysfunction pump – male dysfunction pills ed pills don t work
ventolin cost uk – ventolin online albuterol nebulizer
accutane 40 mg price – accutane 5 mg 10mg accutane usa
methylprednisolone 24mg – cost for lyrica purchase lyrica
buy cheap sildenafil – sildenafil samples sildenafil online canada
stromectol covid – stromectol for humans ivermectin 50
brand name vardenafil online – vardeed erectile dysfunction doctor
where can you purchase female viagra – genuine viagra 25 mg viagra
canadianpharmacyworld com – Cialis discount cheap generic cialis canada
ivermectin 12mg pills for humans – ivermectin cost generic ivermectin
synthroid 150mcg pills – neurontin pills order gabapentin 100mg pills
buy sildalis generic – diflucan online order glucophage 1000mg sale
order ampicillin for sale – flagyl 400mg for sale hydroxychloroquine 400mg for sale
viagra 50mg ca – order cialis 20mg pill buy tadalafil
acheter 50mg du viagra – tadalafil 20mg sans ordonnance tadalafil 5mg comprimГ©
purchase prednisone without prescription – prednisone tablet prednisone cheap
oral isotretinoin – norvasc price purchase amoxil generic
order lyrica online – ventolin inhalator online azithromycin 250mg generic
buy tadalafil tadalafil daily online
buy tizanidine online – gloperba tablet buy gloperba online cheap
https://cialisicp.com/ tadalafil price walmart
tadalafil goodrx tadalafil generic
cialis cost https://cialisedot.com/
https://cialisedot.com/ tadalafil online with out prescription
side effects for tadalafil cialis without a prescription
where to buy cialis without prescription tadalafil price walmart
tadalafil daily online tadalafil order online no prescription
cheap generic cialis for sale side effects of tadalafil
cialis tadalafil tadalafil cost in canada
http://ivermectinetc.com/ buy stromectol 6 mg