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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:05:37+00:00 2026-06-16T04:05:37+00:00

I am trying to align the modal box ( in this case it’s a

  • 0

I am trying to align the modal box ( in this case it’s a confirm box ) in the center of the page. So I set the position of the main container to be relative and then positioned the div element of the modal box using the following CSS code:

.confirmBox{
    top:25%;
    left:25%;
}

I have adjusted the values of the top and left attributes. This works fine at lower zoom but as I zoom in the box does not remain in the center of the page. How can I solve this using CSS?

The original code is actually big and i am not able to think of an instance for this case.
Still I am considering the div element with class=”confirmBox” to be the code for confirmBox and attaching the fiddle http://jsfiddle.net/W6ATN/47/.

  • 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-16T04:05:38+00:00Added an answer on June 16, 2026 at 4:05 am

    You can use 50% left and top positions, and then subtract half of the width and height to make up for the size of the element:

    position:absolute;
    top:50%;
    height: <your value>px;
    margin-top: (negative value of your height, divided by 2);
    width:<your value>px;
    left:50%;
    margin-left: (negative value of your width, divided by 2);
    

    I think this way is easier to understand. If the width of the element is 40% (of its container), then it should be 30% to the left to be equally centered:

    |-----30%-----|-------40%--------|-----30%-----|

    which all == 100%

    Or

    you can use % width and % height, and use simple math to figure out the left and top positioning:

    position:absolute;
    height:40%;
    width:40%;
    left:30%; // (100 - width) divided by 2
    top:30%; // (100 - height) divided by 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to align a textblock vertically and horizontally center in a stack
I am trying to center align my google chart but have been unsuccessful in
I'm trying to build up a simple JQuery function : A modal box (one
Im trying to align a jquery popup div to the center of my screen
I'm trying to simulate a floating modal box type thing but having an issue
I'm trying to position my picture a little bit lower so the center of
I have been trying to align an entire label along with text to the
Problem: I am trying to align divs next to each other using float:left but
I'm trying to align an ImageView to the top of the screen with a
I'm trying to align a text horizontal and vertically. Using de horizontal axis, I

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.