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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:46:25+00:00 2026-05-15T13:46:25+00:00

Why does all content get jerked downwards before fading in the following, and how

  • 0

Why does all content get jerked downwards before fading in the following, and how can i fix it?
Using FireFox 3.6.3, thanks in advance.

<html>
    <head>
        <script type="text/javascript" language="javascript" src="http://localhost/javascript/jquery-1.4.2.js"></script>
        <script type="text/javascript" language="javascript">
            $(document).ready(function(){   
                $("#button").click(function(){
                    $("*").fadeTo("slow",0.0);
                }); 
            });
        </script>
    </head>
    <body>
        <p>Just a normal paragraph doing my job!</p>
        <p>Me too!</p>
        <input type="button" id="button">
    </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-15T13:46:25+00:00Added an answer on May 15, 2026 at 1:46 pm

    It has something to do with trying to fade all elements, including those outside the <body>. Try:

    $("body > *").fadeTo(..)
    

    But why would you want to fade every single element, when you can simply do a fade on the body itself.

    $("body").fadeTo(..)
    

    Edit: Some more research shows that when trying to fade the <style> and <head> elements, in no particular order, causes everything to move down. Don’t know why yet, but you can see an example here – http://jsfiddle.net/UKn8r/2/

    Edit 2: Ok, I think I may have a reason here. The <head> and its children elements such as <style>, <script>, etc. are by default set to display: none in the user agent’s stylesheet. When fading them out, jQuery ends up setting their display property to display: block. Now the contents of these child elements are not meant to be displayed on the screen, but by setting them to display: block, it gets displayed as a horizontal block about 20px high with no content, which shifts everything else downwards. Note that if you were to empty out the <script> element and make the onclick inline, then you wouldn’t see the jump on Firefox since the element will be empty and not consume any space on screen even when displayed as a block. So changing it to:

    <html>
        <head>
            <script src="http://localhost/javascript/jquery-1.4.2.js"></script>
        </head>
        <body>
            <p>Just a normal paragraph doing my job!</p>
            <p>Me too!</p>
            <input type="button" id="button" onclick='$("*").fadeTo("slow",0.0);'>
        </body>
    </html>
    

    will not cause any jumps.

    Also, your original code verbatim, will work properly on Webkit browsers (Chrome, Safari) as the display style property for <script> elements does not get overridden as block. For these browsers, however, if you were to have a style element with some content inside it, then you would see the same behavior as <style> will have an inline style attribute having display: block. Now it may seem utterly useless to have something like, <style style="display: block; opacity: 0">..</style>, but this is just an explanation for why you’re seeing the behavior that you’re seeing. So to reproduce the same problem on these browsers, try this code:

    <html>
        <head>
            <script src="http://localhost/javascript/jquery-1.4.2.js"></script>
            <style>p {}</style>
        </head>
        <body>
            <p>Just a normal paragraph doing my job!</p>
            <p>Me too!</p>
            <input type="button" id="button" onclick='$("*").fadeTo("slow",0.0);'>
        </body>
    </html>
    

    The <style> property must have some content, and not pure whitespace, so I put the junk p {} there.

    This concludes my wasteful search for something that shouldn’t be done in the first place 🙂

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

Sidebar

Related Questions

How can I get all content between pipes and return a space where it
Basically I can't get the div that holds all the content to move down
I have a ColdFusion script that does: <cfset content = replace(content,&##147;,,all)> Which replaces &147;
I have the following XAML, that does all that it is supposed to, except
How can i remove this <p> tag with all its content in javascript? say
I get the following Error: jquery1.4.2.js Line: 2828 Error: The Object does not support
For some reason i can't get the variable 'total' to define at all... I
I have an existing application which does all of its logging against log4j. We
I understand that the browser does all the work in processing client side scripts
I have made an class which conforms to the NSCoding protocol and does all

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.