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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:03:08+00:00 2026-05-26T12:03:08+00:00

Here is my code: dialog = $(this).closest(‘.ui-dialog’) dialog.animate({ left: document.width – dialog.width(), // or

  • 0

Here is my code:

dialog = $(this).closest('.ui-dialog')
dialog.animate({
    left: document.width - dialog.width(), // or you might want to use .outerWidth()
    top: document.height - dialog.height()
}, 1000);

I want to position jQuery dialog at the center of the page with animation. I just do not understand why it is not working. Can anyone help me?

  • 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-26T12:03:09+00:00Added an answer on May 26, 2026 at 12:03 pm

    I actually prefer position:fixed. Here is a simple demo of a dialogue that transitions to the center of the browser window.

    Demo: http://jsfiddle.net/FJPjQ/show
    Source: http://jsfiddle.net/FJPjQ/


    Basically it takes a position:fixed div and gives it a left value of 50% and a top value of 50%. This places the top left corner of the dialogue in the center of the window. To make the dialogue itself center, you can then give it a top margin of negative half its height and a left margin of half its width.

    jQuery

    var dialogue = $('.ui-dialog')
    
    dialogue.animate({
        left: "50%",
        top: "50%",
        marginLeft:  -dialogue.width()/2,
        marginTop: -dialogue.height()/2
    }, 1000);
    

    HTML

    <div class="ui-dialog">hi there</div>
    

    CSS

    .ui-dialog
    {
        width: 200px;
        height: 50px;
        background: red;
    
        /* change these to change where it slides in from */
        top: -100px;
        margin-left: -100px;
        left: 50%;
    
        /* and this is what makes it work */
        position: fixed;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code here: var infiltrationResult; while(thisOption) { var trNode = document.createElement('tr'); var
I use the jQuery Tools Overlay plugin and I have this code here <script
Ok the error is showing up somewhere in this here code if($error==false) { $query
See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
I have this code here, which is intended to allow any type of arguments:
Here's the code: protected Dialog onCreateDialog(int id) { Dialog dialog = null; if (id
I need a custom dialog to appear on button press. Here is my code:
Here my JS code $(function () { $(.button).live(click, function () { alert(Dialog page function
I've got this dialog (I'm simplifying my use case): class EditShoppingListDialog extends AlertDialog {
Here is code from MSDN . I don't understand why the work isn't just

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.