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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:28:53+00:00 2026-06-11T23:28:53+00:00

i have one fixed div and that is placed on page using css. i

  • 0

i have one fixed div and that is placed on page using css. i have another div which is dynamically generated and added into form and position at center of page. this div added when click occur on document.

the problem is when i click on document the div dynamically added onto page and position properly but the static div position getting change. i just do not understand why it happens.
here is my code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
        $(document).ready(function () {
            $(document).click(function (e) {
                // Check for left button click
                if (e.button == 0) {
                    $('form').append('<div id="dvfloat" class="float_div">Welcome</div>').center().fadeIn('slow');
                }
            });

            jQuery.fn.center = function () {
                this.css("position", "absolute");
                this.css("top", Math.max(0, (($(window).height() - this.outerHeight()) / 2) +
                                                $(window).scrollTop()) + "px");
                this.css("left", Math.max(0, (($(window).width() - this.outerWidth()) / 2) +
                                                $(window).scrollLeft()) + "px");
                return this;
            }
        });
    </script>
<style type="text/css">
.login_div {
    background-color: Yellow;
    margin-left: 50px;
    position: absolute;
    width: 100px;
}
.float_div {
    background-color: Green;
    width: 100px;
    height:50px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
    <div id="static_dv" class="login_div"> hi how r u ? </div>
</form>
</body>
</html>

please run my code and see the effect. static div called “static_dv” getting re-position when i click on document but i did not write any code to do so. i want static div should change its position. what will be the fix. thanks

  • 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-11T23:28:54+00:00Added an answer on June 11, 2026 at 11:28 pm

    You’re not actually centering the newly created DIV, but the whole form, try with this little change:

    $('form').append('<div id="dvfloat" class="float_div">Welcome</div>').fadeIn('slow');
    $('#dvfloat').center();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one div position:fixed; and my problem is that position fixed is relatively
I'm putting together a fixed, one-page site that deploys an overlay using jQuery. There
I have one div with position:fixed 0 ; that stays on the top of
I have one drop down list in my page, which contains two options. What
I have a span, which is inside a div of fixed width. The span
so I have a page that has a fixed link bar on the side.
I have a div (with a fixed width) that has 2 image elements as
I'm using the Tab Slide Out Jquery plugin. http://wpaoli.building58.com/2009/09/jquery-tab-slide-out-plugin/ I have one tab that
I have some facebook style header div which is position:fixed. So all the rest
I have a HTML page with a CSS print layout where I want one

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.