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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:37:17+00:00 2026-05-13T20:37:17+00:00

Please look at the following test page : sample page showing two images .

  • 0

Please look at the following test page :
sample page showing two images.

You see small images which get a bit enlarged when you move over the image.

I have used jQuery to do this, but ran into the following problem.

The only way I got the wanted effect was to enlarge the white <div> and making the image a percentage of the encapsulation <div>. If the <div> gets enlarged, the image automatically gets enlarged too.

Howerver, as you see on the sample page, the percentage a have choosen, enlarges to image so, that a 1 pixel out of alignment is visible (the right border is 1 pixel larger than the other pixels).

I could, of course, choose another percentage, but in stead want to ask the following question (being a programmer, I want to know how to solve similar problems, not this one in particular).

I would like to be able to AND enlarge the <div> AND enlarge the <IMG> during the same hover action – that way I could make sure that the enlarged image is the correct size.

I tried a couple of things, but never got the result – can anybody help me here ? Any help would be highly appreciated. I am learning to use jQuery and need to see some ways how to do things before I really can start using it.

The code of the page is below : (snippet from an existing page where I now want to include the enlarging effect – colours are just to see the different -areas).

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  <html lang="en">
  <head>
  <title>enlarge image with jquery</title>
  <script type="text/javascript" src="http://www.sitestepper.com/versie2009/_js/jquery-1.4.min.js"></script>
  <style>
  html,body { margin:0; padding:0; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; }
  *         { margin:0; padding:0; }

  img { border:none }

  .grid7x12jq {
     width:990px;
     height:260px;
     margin:10px 0 10px 10px;
     padding:9px 0px;
     clear:both;
     background-color:#ffddff;
  }
  .grid7x12jq .griditem {
     position:relative;
     width:137px;
     height:267px;
     float:left;
     border:none;
     padding:0px;
     margin-right:2px;
     margin-bottom:16px;
     background-color:#caffff;
  }
  .grid7x12jq .imgbox {
     position:absolute;
     left:0px;
     top:0px;
     border:none;
     width:137px;
     height:129px;
     margin:0;
     padding:0;
     clear:both;
  }
  .grid7x12jq .artbox {
     position:absolute;
     left:0px;
     top:138px;
     text-align:center;
     font-size:11px;
     border:none;
     padding:0px;
     width:137px;
     height:48px;
     line-height:14px;
     margin:0px;
  }

  .band-foto {
     position:absolute;
     left:10px;
     top:10px;
     width:118px;
     height:118px;
     background-color:white;
     border:1px solid black;
  }
  .band-foto img {
     width:88%;
     height:88%;
     padding:7px;
     /*position:absolute;*/
  }

  </style>

  </head>
  <body>
  <h1>jQuery Test - Enlarge images</h1>
  <script type='text/javascript' src='http://www.sitestepper.com/versie2009/_js/jquery-1.4.1.min.js'></script>

  <div class='grid7x12jq'>

     <div class='griditem'>
        <div class='imgbox'>
           <div class='band-foto'>
              <a href='http://www.adin.be/en/2ndpage.asp?dtn=07032-0181&amp;titel=Estate collier with brilliant and emeralds'><img
                 src='http://www.adinimages.com/low/07032-0181.P00.JPG' height='100%' width='100%' alt='Estate collier with brilliant and emeralds'/></a>
           </div>
        </div>
        <div class='artbox'>
           <div style='height:30px;'>
              estate collier with bri...
           </div>
           3 photos ca.1970<br/>
             <a href='http://www.adin.be/en/2ndpage.asp?dtn=07032-0181&amp;titel=Estate collier with brilliant and emeralds'>view product</a><br/>
             online price:<br/>&euro; 99999<br/><br/>
             <form class='addbasketbutton' action='http://www.adin.be/en/action_-_sh_put_in_basket_(01).asp?BskDT=07032-0181' method='post'>
                <input type='submit' value='Add to basket'/>
             </form>
        </div>
     </div>

     <div class='griditem'>
        <div class='imgbox'>
           <div class='band-foto'>
              <a href='http://www.adin.be/en/2ndpage.asp?dtn=07032-4420&amp;titel=Estate collier with brilliant and emeralds'><img
                 src='http://www.adinimages.com/low/07032-4420.P00.JPG' height='100%' width='100%' alt='Estate collier with brilliant and emeralds'/></a>
           </div>
        </div>
        <div class='artbox'>
           <div style='height:30px;'>
              estate collier with bri...
           </div>
           3 photos ca.1970<br/>
             <a href='http://www.adin.be/en/2ndpage.asp?dtn=07032-4420&amp;titel=Estate collier with brilliant and emeralds'>view product</a><br/>
             online price:<br/>&euro; 99999<br/><br/>
             <form class='addbasketbutton' action='http://www.adin.be/en/action_-_sh_put_in_basket_(01).asp?BskDT=07032-4420' method='post'>
                <input type='submit' value='Add to basket'/>
             </form>
        </div>
     </div>

  </div>

  <div class='clear'></div>

  <script type="text/javascript">
  $(document).ready(
   function()
   {
     $('.band-foto').hover(
       function()
       {
        $(this)
            .animate({ left:'5px', top:'5px', width:'130px', height:'130px'}, 'fast');
       } ,
       function(){
        $(this)
            .animate({ left:'10px', top:'10px', width:'118px', height:'118px'}, 'fast');
       }
     );
   }
  );
  </script>

  </body>
  </html>
  • 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-13T20:37:18+00:00Added an answer on May 13, 2026 at 8:37 pm

    I don’t typically use animate, so I’ll leave it to you to fill in the specifics, but jQuery lets you stuff as many functions in an event as you can handle–and even allows for chaining, meaning you can grab the selector and just keep going (so long as you are still on or can get back to the right object). So that’s what I’d do: go find the image and animate it, too.

    (Numbers are just guesses. And I changed formatting to save space.)

    function(){
     $('.band-foto').hover(
       function(){
        $(this)
          .animate({ left:'5px', top:'5px', width:'130px', height:'130px'}, 'fast')
          .find("img").animate({ width:'120px', height:'120px'}, 'fast');
       } ,
       function(){
        $(this)
          .animate({ left:'10px', top:'10px', width:'118px', height:'118px'}, 'fast')
          .find("img").animate({ width:'100px', height:'100px'}, 'fast');
       });
    });
    

    Now, there might be a lag, I’m not sure. If so, you could try unchaining it and just making it into two ($(this).animate() and $(this).find()), but this might suffer from the same fate. My gut says you want to refigure your CSS so that the DIV is only as big as the image plus padding, and so animating the image is all you need to do.

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

Sidebar

Related Questions

Let's look at the following piece of code which I unintentionally wrote: void test
Please look at the following code mydiv1.innerHTML=mydiv1.innerHTML + '<label>*Functional Area:<span class=small>Enter Company Name</span></label><input type=text
Please look at the following two examples: Example 1: $variable = 'some value'; class
am new here. i have a slight problem; PLease look at the following code
Getting the above error in following code. How to rectify it. Thanks. Please look
Please take a look at the following .htaccess ErrorDocument 404 /404/ RewriteEngine On RewriteRule
In my current project, Workflows have comments. Please have a look at the following
Please look at the code at the end to see the method I've been
Please look at the two examples below: irb(#<ActionView::Base:0x2863d58>):030:0> paintings_path => /some-nice-alias-path irb(#<ActionView::Base:0x2863d58>):029:0> self.controller_name.to_s +
Please look at : http://news.bbc.co.uk/2/hi/europe/8592380.stm The content updates automatically, however, I can't see it

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.