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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:34:21+00:00 2026-06-10T13:34:21+00:00

Here is what I want to do: I have a pop up widget that

  • 0

Here is what I want to do: I have a pop up widget that appears when the user clicks on a link.

What I need is to position this widget in the middle of the screen no matter how up or down the user has scrolled, but not stop him from scrolling the page after the pop up becomes visible.

Since I can’t know where the widget will be appended (it gets created dynamically), I don’t think a CSS solution is good for me

The widget is written in jQuery

This is the code that currently does the positioning when the user clicks on the link:

$(this).css({
        position: 'absolute',
        top: $(document).scrollTop() + $(this).height() / 2,
        left: '50%',
        'margin-left': -($(this).width()/2),
        'z-index': 50
    });

This works just fine, but I’m having problems when the widget is inside a relatively positioned element.

  • 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-10T13:34:22+00:00Added an answer on June 10, 2026 at 1:34 pm

    You should create a <div id="widgetContainer"></div> at the top of the body and move your active widget into it when the user clicks the link. This will resolve the issue of relative positioning. You can use jQuery’s clone() method.

    function showWidget(id)
    {
        /* Perform other actions to setup your widget */
        $('#widgetContainer').html("");
        $('#' + id).clone().appendTo('#widgetContainer');
    }
    

    Remember to make widgetContainer relative (CSS)

    #widgetContainer {
        position: relative;
    }
    

    And if you use @Simon-Arnolds CSS fix along with this, should solve your issues

    left: $('body').width() / 2,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's what I want to do. I have a form that the user fills
To explain my question I have created this http://jsfiddle.net/Jams/XNVB2/ here I want when div1
James here. I'm working on a site that I want to have the same
I want to provide a link to close the fancybox pop-up window. Here is
Here is what I want to implement: I have two hyperlinks that are displayed
At the moment I have a widget which, when the user clicks on it,
I want to make sure the user wants to have something pop up by
I have this table I want to click on the link and the file
Here goes: I have a view that looks like this: public interface IAddressView {
I have this code in jQuery, that I want to reimplement with the prototype

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.