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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:10:39+00:00 2026-05-30T13:10:39+00:00

I have a small jQuery based script for animating the border on images that

  • 0

I have a small jQuery based script for animating the border on images that you hover upon.

$(document).ready(function(e) {
    $(".oa-article a img").mouseover(function(e)
    {
        $(this).css('border-style', 'solid');
        $(this).css('border-color', '#C63');
        $(this).animate(
        {
            borderWidth: "5px",
        }, 100, function() 
        {
            // Animation complete.
        });
});


$(".oa-article a img").mouseleave(function(e)
    {
        $(this).animate(
        {
            borderWidth: "0px"
        }, 200, function() 
        {
            // Animation complete.
        });
    });

});

The problem is; when that border is animated to 5px, it (obviously) adds those pixels to the width and height, and that results in some unwanted repositioning of other image links next to it (it’s a gallery that has 4 images in a row, and so on).

I tried to absolute position them, but that borked the parent/child behavoiur thus making the page not grow from the images. The thing is though, the absolute positioning made it work like I wanted to. The border grew and did not affect any of the other image positions. That is what I want: When the border grows from 0 to 5 px, I don’t wan’t anything else to be affected by this in any way.

Any help would be greatly appreciated,
Thanks!

  • 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-30T13:10:40+00:00Added an answer on May 30, 2026 at 1:10 pm

    box-sizing: border-box makes for the border to be included in the width/height (so that adding a border doesn’t make the element grow): http://jsfiddle.net/8GdZy/1/.

    img {
        box-sizing: border-box;
    }​
    

    The image itself is then shrinked.

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

Sidebar

Related Questions

I have a jquery function that is called on $(document).ready that modifies the css
I have a small jQuery script: $('.field').blur(function() { $(this).next().children().hide(); }); The children that is
peace folks, I have this small piece of jquery based code, that grabs all
I have this small jquery script that does not work if I remove the
I have a small jQuery plugin that I use for form AJAX validation. There
I have a small jquery snippet that displays notification message at the top of
I have a page that uses jQuery with a small glitch. I managed to
I have a small ajax jquery script which returns some XML for me. Whilst
I have written a small jQuery plugin with the following structure: (function($) { //
I have a small jQuery snippet which animates an image caption, based on the

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.