Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 156333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:18:42+00:00 2026-05-11T10:18:42+00:00

I need to display user entered text into a fixed size div. What i

  • 0

I need to display user entered text into a fixed size div. What i want is for the font size to be automatically adjusted so that the text fills the box as much as possible.

So – If the div is 400px x 300px. If someone enters ABC then it’s really big font. If they enter a paragraph, then it would be a tiny font.

I’d probably want to start with a maximum font size – maybe 32px, and while the text is too big to fit the container, shrink the font size until it fits.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:18:43+00:00Added an answer on May 11, 2026 at 10:18 am

    This is what I ended up with:

    Here is a link to the plugin: https://plugins.jquery.com/textfill/
    And a link to the source: http://jquery-textfill.github.io/

    ;(function($) {     $.fn.textfill = function(options) {         var fontSize = options.maxFontPixels;         var ourText = $('span:visible:first', this);         var maxHeight = $(this).height();         var maxWidth = $(this).width();         var textHeight;         var textWidth;         do {             ourText.css('font-size', fontSize);             textHeight = ourText.height();             textWidth = ourText.width();             fontSize = fontSize - 1;         } while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);         return this;     } })(jQuery);  $(document).ready(function() {     $('.jtextfill').textfill({ maxFontPixels: 36 }); }); 

    and my HTML is like this

    <div class='jtextfill' style='width:100px;height:50px;'>     <span>My Text Here</span> </div> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement wherein I need to display on a User form, a
When typing in my URL SalaryFor/Microsoft/Balmer i need to display salary for user with
I have a need to display a UITableView containing a user's account credentials. For
I need to display a variable-length message and allow the text to be selectable.
How can i handle user inputs with textarea, i need to strip user entered
I am new to PHP and i need to know how to display entered
Scenario: I have multiple text boxes in which a user will enter data into
In my android app I need to display a text on an image. The
I have an unusual project that I need to display large sets of questions
i am developing one application with map view i need display the weather depends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.