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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:34:05+00:00 2026-05-28T17:34:05+00:00

I want to have an element with a fixed, small height that expands to

  • 0

I want to have an element with a fixed, small height that expands to his full height on a mouseover and shrinks back when mouse leaves.

Doing something like:

    $(".element").each(function() {
    $.data(this, 'size', { width: $(this).width(), height: $(this).height() });
}).hover(function() {
    $(this).stop().animate({ height: $.data(this,'size').height, 
                             width: $.data(this,'size').width });
}, function() {
    $(this).stop().animate({ height: 40, 
                             width: $.data(this,'size').width });
}); 

…works, but on page load the element starts at full height.

What is the best way to have it shrinked on page load ?

  • 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-28T17:34:06+00:00Added an answer on May 28, 2026 at 5:34 pm

    try it like this, it is better to understand. check fiddle example. In this way you can even add other animation effect like changing background color …..

    CSS:

    .div_small_height{
     height : 20px;
     width : 500px;
     background-color : red;
     overflow : hidden;
    }
    .div_full_height{
       width : 500px;
       background-color : blue;
    }
    

    Jquery:

    $(".element").addClass('div_small_height'); // shrink it on page load
     // change on mouseenter and mouse leave
    $(".element").hover(function(){
        $(this).switchClass("div_small_height","div_full_height",500);
    },function(){
        $(this).switchClass("div_full_height","div_small_height",500);
    });
    

    fiddle example : http://jsfiddle.net/7PV98/

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

Sidebar

Related Questions

I have a fixed width element that I want to essentially shoot off the
I want to have a element that displays in the multiple selection display style
I have an element that is fixed and has a margin from the left
I have a <input> element that I want to change the background color on.
I have an element I want to be shown whenever the cursor is moved
i have some element in my container and want to save all properties of
I have an element in GWT. I want it to float right. I have
we want to have the second biggest element. We first use ANY to exclude
I have an element: <select id=row /> I want to append a string to
I have an element, like this: <div id=navleft> </div> I want to make this

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.