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

  • Home
  • SEARCH
  • 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 6936495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:14:28+00:00 2026-05-27T12:14:28+00:00

I have a div inside another div. The outer div has a starting width

  • 0

I have a div inside another div. The outer div has a starting width & height of 0px & slowly increases in width & height, which creates the effect of slowly revealing the inner div(from the centre outwards).

I do this using Javascripts setInterval & just increase the dimensions of the outer div every iteration.

Because the outer div is absolutely positioned I find that I need to recentre(horiz & vert) the inner div within the outer div to ensure that I reveal the div from the exact centre outwards as the outer div expands.

Is there an automatic way to ensure that the inner div is always centred within the outer div as it expands? Using CSS or any other method?

The best way I have found is if I change the inner divs position to fixed but then the overflow:hidden(on the outer div) doesnt get adherred to???

<html>
<head>
</head>
<body>

    <!-- Using Javascript I will slowly increase the outer divs width & height: making the innerdiv slowly appear. 
         Although, as the outer div resizes, the inner div will be positioned relativly, how can I keep its position at 20,20 of the body ALL the time? -->
    <div style="position: absolute; background-color: blue; left: 10px; top: 10px; width: 300px; height: 300px; overflow: hidden;">
        <div style="position: fixed; background-color: red; left: 20px; top: 20px; width: 500px; height: 300px;">
        </div>
    </div>

</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-27T12:14:29+00:00Added an answer on May 27, 2026 at 12:14 pm

    If you don’t need IE7 support, I’d suggest you use display:table-cell to achieve the vertical centering.

    http://jsfiddle.net/fte2t/1/

    If you do need IE7, only way will be by use of table, i’m afraid…

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

Sidebar

Related Questions

I have a div inside another div. The outer div has rounded borders using
I have a div inside another dive. Since the outer div has a fixed
I have a div inside another div which has a fixed position at the
I have a div inside of another div. #outer and #inner . #outer has
How can you have one div inside another? The inner div has to fit
I have a div inside another div that has borders on the right and
I have a thumbnail image inside a div. I use another image as the
I have a div inside of a table which is inside of a form
I have a div that has it's opacity set to 60. Inside the div,
I have a relative positioned div inside another div. The inside-div is positioned with

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.