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

The Archive Base Latest Questions

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

I have a page with a bunch of thumbnails. I use DIV with background

  • 0

I have a page with a bunch of thumbnails. I use DIV with background images for the thumbnails. When I hover, I have a jQuery script that animates the DIV to expand the div to the full width of the images. The expansion is in all direction, it expands from the center with some margin and top/left positioning.

Problem is: if I hover on the image that sits right at the top of the page, the image expands but we only see the bottom half because it expanded outside the viewport.

Do you know of a solution to restrict the expansion to the viewport, or to a containing DIV..?

Here’s the code I have:

$("div.thumbnail").hover(function() {

    $margintop = '-70px';  // half the height of big img minus margins/paddings
    $marginleft = '-115px';  // half the width of big img minus margins/paddings
    $width = '348px';
    $height = '258px';

    $(this).css({'z-index' : '1000'});
    $(this).addClass("hover").stop().animate({
        marginTop: $margintop,
        marginLeft: $marginleft,
        scrollTop: 0,
        width: $width,
        height: $height
    }, 200);

    } , function() {
        $(this).css({'z-index' : '0'});
        $(this).removeClass("hover").stop().animate({
            marginTop: '10px',
            marginLeft: '10px',
            top: '0',
            left: '0',
            width: '100px',
            height: '100px'
        }, 150);
});
  • 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-17T20:02:02+00:00Added an answer on May 17, 2026 at 8:02 pm

    I would look at the attributes top, left, right and bottom of the wrapper div of which the images are not to be displayed outside, see if the image max size positions would go past these coordinates and shift the image accordingly to the pixels it exceeds the border with.

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

Sidebar

Related Questions

I have a page that shows a bunch of thumbnails (around 30), and the
I have a bunch of thumbnails that I wish to display in my page.
I have a web page that includes a bunch of images. Sometimes the image
I have a page that loads a bunch of scripts to prepopulate dropdowns and
I have a page where I am loading bunch of images initially when the
I have a page that has a bunch of user controls on it. I
I have a page that will basically be used to concatenate a bunch of
In my page I have a bunch (about 30) dom nodes that should be
I have a page that has a bunch of widgets on it. Each widget
I have a page that dynamically generates any number of divs.  Inside the div

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.