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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:33:46+00:00 2026-05-13T18:33:46+00:00

I have a div. Inside the div is another group of divs that each

  • 0

I have a div. Inside the div is another group of divs that each contain an img. I am trying to setup a mouse over that makes the current img expand using .hover() and .animate(). I wanted the code to figure out whether it was a landscape or portrait image then expand it in width or height not to exceed the bounds of the containing div.

Here’s the code inside of document ready.

$('.clGalleryImage').hover(function() {
    $varHeight = $('.clGalleryImage:hover').height();
    $varWidth = $('.clGalleryImage:hover').width();
    if($varHeight > $varWidth) {
        $('.clGalleryImage:hover').animate({marginTop:0, height:125}, 'slow');
    } else {
        $('.clGalleryImage:hover').animate({marginLeft:0, width:125}, 'slow');
    }
}, function() { 
    ...
});

The handlerOut part of the .hover is incomplete so ignore that. The problem is with the handlerIn. When I hover over an img that is portrait the function works great. The image grows in width and height proportionally and stops growing at the border of the containing div. But when I hover over a landscape img (the else in the code above) it only grows in the width, not height proportionally. Is this by design?

I apologize if this is a newbie question but it has been bugging me all day. Eventually I coded it to work manually around the images I chose. I’d rather the code work with whatever the proportions of the image, then have to edit the image prior to using it.

Thanks

I suppose I should include the div and the CSS.

The div

<div class="clGalleryImageContainer">
    <img class="clGalleryImage" src="/New/Images/Molds/Molds001_th.jpg" alt="Mold Gallery Image 001" title="This is some description Text." />
</div>

The CSS

.clGalleryImage { display:block; height:100px; margin-left:auto; margin-right:auto; margin-top:12px;}
.clGalleryImageContainer { position:relative; float:left; width:150px; height:125px; border: 1px solid white; background-color:black; margin-top:12px; margin-left:21px; margin-bottom:12px;}
  • 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-13T18:33:46+00:00Added an answer on May 13, 2026 at 6:33 pm

    You have the height set in the CSS height:100px; so .animate() will respect this style and leave it throughout the animation. In the other animation, you’re explicitly telling it to change the height, so it will.

    So the answer would be yes, this is by design.

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

Sidebar

Related Questions

I have an 3 images inside a div and that div is inside another
I have two divs one inside another, i would like to overlap one div
I have a div (maincontent) which is inside another div (container). These divs are
I have a div inside another div that has borders on the right and
I have a div containing a group of divs. I want the divs inside
I have a Main div inside which i am trying to display another small
I have an opaque div.opaque containing another div.inner. Since inner div is contained inside
I have a thumbnail image inside a div. I use another image as the
I want to append a div inside a div which have many divs inside
I have three div layers inside of another larger one. Something like this: Image

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.