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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:14:10+00:00 2026-06-01T21:14:10+00:00

On my website i have a div with an absolute position in a parent

  • 0

On my website i have a div with an absolute position in a parent div. What I want is when I click the div it has to enlarge and position in the middle of my browser.

What i tried is this:

$j("#mac").click(function(){
 $j('#mac').css({
        position: 'fixed'
    });

$j('#mac').animate({
    width: 923,
    height: 498,
    left: ($j(window).innerWidth() - 923)/2,
    top: ($j(window).innerHeight() - 498)/2
  }, 1000)});

It worked but what happened is that the #mac first positioned to the left top corner of my screen and than animate to the center of my screen. This make sense because of the usage of position fixed. But when I dont use that position the div wont position at the center.

So i don’t want to have te postioning at the left top corner of the screen but the div have to animate from his original position to the center of the screen.

Somebody know how to do this?

Thanks in advance!

  • 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-06-01T21:14:12+00:00Added an answer on June 1, 2026 at 9:14 pm

    When you change the CSS position to fixed, at the same time, find the current top and left positions of the DIV and set those as well. That should start the animation at the correct place.

    var offset = $j('#mac').offset();
    
    $j('#mac').css({
        position: 'fixed',
        top: offset.top,
        left: offset.left
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making website that have notification 'button'. When user click this button, notification div
Good Day, I used position:absolute for many div's in my website. I have used
Let's say I have this element for displaying the website logo: <div id="web-title"> <a
It's my understanding that position: absolute is absolute to the first parent who has
I have a website with a backgroundimage in a <div> element that has another
I have two div in my website page one beside the other(one left and
I have an div element in website markup as follows. <div id=mainContainer class=container runat=server>
I have website, usually all looks fine but sometimes one div is on the
I am working on a website where I have a main div . I
I have a website with a centered fixed width div (the div is centered

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.