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 8730291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:59:29+00:00 2026-06-13T08:59:29+00:00

Alright, so here’s what I’m trying to do. Let’s say I have the following

  • 0

Alright, so here’s what I’m trying to do. Let’s say I have the following HTML:

<div id="test">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>

And the following CSS:

#test {
    height: 100px;
    min-width: 100px;
}

Now, let’s imagine that the paragraph in the HTML above can be of variable length. Or maybe there are two paragraphs. It doesn’t really matter. What I’m looking for is a CSS or jQuery way to have the div always remain 100 pixels tall, and to end up no less than 100 pixels wide, but no wider than is necessary to prevent vertical overflow.

So, if the contents are short enough—say, a single word—the div will have a height of 100 pixels and a width of 100 pixels. If the contents is an entire paragraph, the div will still have a height of 100 pixels, the contents will fill it vertically, and the div will expand horizontally only enough to prevent overflow.

  • 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. Editorial Team
    Editorial Team
    2026-06-13T08:59:30+00:00Added an answer on June 13, 2026 at 8:59 am

    Use a while loop to compute the height of the inner paragraph, and continually adjust the width of the parent div until it fits.

    while ($('#test > p').height() > $('#test').height()) {
        $('#test').width($('#test').width() + 1); // or +5 or +10 for a faster result
    }
    

    http://jsfiddle.net/mblase75/MFHah/

    Warning: this may cause infinite loops in certain circumstances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so here is the situation... Say I have a navbar for a site,
Alright, here is my problem i'm trying to solve. I have an index page
Alright so here is the question. I have a user class which contains a
Alright, here I am again trying to write code from scratch and I can't
Alright here is the thing, I have this site that was once wordpress but
I'm trying to generate ics-files, see sample here: http://deap.nu/myprogram.ics It validates alright here: https://icalendar.org/validator.html
Alright, Here's the gist of what I'm planning to do. I'm going to have
Alright, so here is the property I have public List<String> names{ get{ lock(_names) return
Alright, so here's my problem. I'm trying to write a script in PHP that
Alright here's the situation, I have an application written in the Zend_Framework, that is

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.