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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:46:38+00:00 2026-05-27T16:46:38+00:00

I made a toggle that expands a div if you click a read more

  • 0

I made a toggle that expands a div if you click a read more link:

$(".user-review-toggle").toggle(function(){
    // Change the height of the element to auto so we can get that value, and use it in our expanding animation.
    var currentUserReview = $(this).prev('.user-review');
    currentUserReview.css('height', 'auto');
    var calculatedHeight = currentUserReview.height();

    $(this).css("display", "none");
    $(this).css("backgroundPosition", "0 -12px");
    currentUserReview.animate({height: calculatedHeight}, 0, function () {
        $(this).css("overflow", "visible");
        $(this).css("line-height", "140%"); // Change it back to the original value
    });

The height of the div when the text is collapsed:

.has-photo .user-contribution .user-review, .has-review .user-contribution .user-review {
height: 98px;
}

It first temporally set the div’s height to auto so it can store its original size. Then it animates the height’s of the div to that height.

The problem now is that it expands excessively when there are a lot of characters and don’t expand enough when there are too few. Having an image beside the text also makes the final result a bit unexpected (as you can see int he screenshot):

Collapsed:
enter image description here

Expanded:
enter image description here
Any suggestions to fix this?

  • 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-27T16:46:38+00:00Added an answer on May 27, 2026 at 4:46 pm

    Are you setting with & height to your images? Try doing that. When images are not loaded they do not use any space at all. Try to set the dimensions of the images.
    Hope that helps.

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

Sidebar

Related Questions

I have made my Toggle() function that alternates an image (changes the images to
I'm using PDO inside a database abstraction library function query that I've made. I'm
i made a small menu with <ul> <li> : js: $('#ulAcoesCliente li').click(function(ev) { $(.ulNone).each(function(){
I have a basic toggle switch that shows the clicked on div while closing
In the page Toggle Squares , I have a table made out of an
Made solution change: I am trying to display a html table of data.. In
Made this nice little loop for hiding and showing div's, works as a charm
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I made a code that translate strings to match each word from the array
I made and use this one, but I know theres better ways : function

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.