Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery animate div when its wrapper start to "disappear" at the top
    primarykey
    data
    text
    <p>I have a header. Below that header I have a wrapper containing 2 divs positioned side by side. I would like to have the right div being animated when the wrapper it belongs to (#wrapper) start "disappearing" at the top of the page. I tried $(window).scroll but the problem is that the animation starts even if the wrapper has not starting to disappear at the top. I hope I explained my problem clearly. Thank you in advance for your replies. Cheers. Marc.</p> <p>My HTML :</p> <pre><code> &lt;div id="header"&gt;&lt;/div&gt; &lt;div id="wrapper"&gt; &lt;div id="contentWrapper"&gt; &lt;div id="contentOne" class="content"&gt;This is contentOne&lt;/div&gt; &lt;div id="contentTwo" class="content"&gt;This is contentTwo&lt;/div&gt; &lt;div id="contentThree" class="content"&gt;This is contentThree&lt;/div&gt; &lt;div id="contentFour" class="content"&gt;This is contentFour&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>My CSS:</p> <pre><code>#header{ width:960px; height:300px; background-color:rgba(1,1,1,0.3); margin:5px auto;} #wrapper{ width:960px; height:auto; margin:0 auto; background-color:rgba(238,221,130,0.6); border:5px solid purple; overflow:hidden;} #contentWrapper{ width:1910px; height:auto; background-color:rgba(70,130,180,0.4); float:left; position:relative;} .content{ width:465px; height:auto; margin:10px 0 10px 10px; padding:0; background-color:rgba(205,92,92,0.4); float:left;} #contentOne{ height:2000px;} </code></pre> <p>My JS :</p> <pre><code>$(window).scroll(function() { $("#contentTwo").stop().animate({ "marginTop": ($(window).scrollTop() + 10) + "px" }, "fast"); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload