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

  • Home
  • SEARCH
  • 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 6098291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:08:29+00:00 2026-05-23T13:08:29+00:00

I have a div with the following CSS: #feedback { min-height: 24px; line-height: 24px;

  • 0

I have a div with the following CSS:

#feedback {
  min-height: 24px;
  line-height: 24px;
  margin-bottom: 10px;
  display: none;
}

Then I add some content using jQuery.

jQuery('.feedback_text').html(feedback.message);
jQuery('.feedback_icon').addClass(feedback.type);
jQuery('#feedback').fadeIn('normal', function() {
  jQuery(this).height('100%');
});

The problem is that when I have more than one line of text, the DIV does not expand.

I’ve tried using $('.feedback_text').height(), but it only gives me the height specified in the CSS (24px) and not the height after dynamic content was added.

Any suggestions anyone?

  • 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-05-23T13:08:30+00:00Added an answer on May 23, 2026 at 1:08 pm

    There shouldn’t be any need to set the height explicitly. Here’s an example on jsFiddle I just made, where you can see your code running and successfully showing a <div> expanded to fit the contents that are set.

    Is there perhaps some other CSS rule affecting your div? What does it look like if you inspect it with a CSS debugger?

    UPDATE: Thank you for providing fuller code. I see from this that your problem is that your container <div> only contains floated elements. Floated elements are taken out of the normal document flow, and don’t affect the height of their container like they normally would. (And also because you’ve set an explicit height on your .feedback_text element, which I’m guessing you didn’t mean to do.)

    The traditional hack/fix for this is to add a final contained element (which can be empty) below the floated elements, set to clear the floats. That forces the containing element to stretch to fit the floated elements. So, you go from this:

    ...
    #feedback span { float: left }
    ...
    <div id="feedback">
        <span class="feedback_icon"></span>
        <span class="feedback_text"></span>
    </div>
    

    to this:

    ...
    #feedback span { float: left }
    .clearfix { clear: both }
    ...
    <div id="feedback">
        <span class="feedback_icon"></span>
        <span class="feedback_text"></span>
        <div class="clearfix"></div>
    </div>
    

    ..and everything should start working. I’ve updated your example to use this technique in this jsFiddle.

    By the looks of what you want to achieve, though, I’m not sure you need to float both elements anyway. Floating the image left and leaving the text non-floating, together with a few other adjustments, lets you get the effect you want but without the clearfix hack. Here’s my final example (note I’ve fiddled with your images, etc., to get a working example.)

    UPDATE: I just came back to this answer after an upvote, and I feel I should share the more modern solution to expanding block elements to contain their floats, which is to add a simple overflow: hidden; to the container. This trick works in all modern browsers, though some may also require a set width, and is probably the simplest way of expanding the div to contain the floats in this question.

    I’ve updated my example jsFiddle to show this working. All it needed was the overflow property on the feedback div for it to work for all my browsers. According to that article, you might need to set an explicit height or width (e.g. width: 100%;) for some versions of Opera or IE, but I’d recommend you give it a blast without it and see if it works in the browswers you’re targeting before bothering with that.

    #feedback {
      overflow: hidden;
      min-height: 24px;
      line-height: 24px;
      margin-bottom: 10px;
      display: none;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following css: .horizontal-holder1{ float:left; width:88px; height:98px; margin-bottom:15px; border:1px solid #bdbdbd; background-color:grey;
Hi I have a following css : div.container { height:20px; overflow: hidden; margin: 15px
I have the following CSS and HTML: div#actionList { float: left; height: 25px; margin:
I have the following css and html... .hide { display:none; } <div> <span class='kardashian
I have a div with following CSS: div { width:600px; height:auto; } Now my
I have the following CSS rules applied to a DIV: .icon { position:relative; display:
I have a <div id=outer> which has the following css: position:relative; width:300px; height:125px; float:left;
Suppose I have the following CSS snippet: div { width: 200px; padding: 10px; border-width:
I have a div that has the following css: position: fixed; height: 100%; left:
I have the following css: #app-info { float: left; margin: 10px 10px; } #app-info

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.