1/31/2024 0 Comments Dynamic auto painter plugins![]() You can set maximum font-size and you can also choose to limit the font-size using either width, height or both. I will work on it.Įdit2: I have now fixed those problems and limitations and added more options. I will work on getting an option to set the maximum font-size.Įdit: I have found some more problems with the plugin, it does not handle other box-model besides the standard one and the div can't have margins or borders. I added some other functionality (rotating text, adding padding) and packaged it as a jQuery plugin, you can get it at:Īnd it will fit nicely on your container.įor now it has some limitations, the div must have a fixed height and width and it does not support wrapping text into multiple lines. I eventually had to write my own algorithm to make it perform in a way that allowed me to update its contents periodically without freezing the user browser. Most of the other answers use a loop to reduce the font-size until it fits on the div, this is VERY slow since the page needs to re-render the element each time the font changes size. Loop through all of the dynamic divs on the page Var textDivs = document.getElementsB圜lassName("dynamicDiv") While(textSpan.offsetHeight > textDiv.offsetHeight) ![]() Var textDiv = document.getElementById("dynamicDiv") Var textSpan = document.getElementById("dynamicSpan") Still, for the sake of reference, here's my original answer: Please check out some of the other wonderful answers here, especially the ones that have found solutions without looping. As much as I love the occasional upvotes I get for this answer (thanks!), this is really not the greatest approach to this problem.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |