Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do it with jQuery or either with <strong>CSS3</strong>, your call, I'll show you both:</p> <h2><em><a href="http://jsbin.com/ikumaf/6/edit">CSS3 demo</a></em></h2> <p>CSS3:</p> <pre><code>#box{ position:absolute; top:100px; left:0; width:200px; height:200px; background:#6CB8E9; -moz-animation:jump 2s infinite ease-in-out; -webkit-animation:jump 2s infinite ease-in-out; } #shadow{ position:absolute; top:290px; height:20px; border-radius:30px; left: -200px; background:transparent; width:200px; box-shadow:200px 0 10px 2px rgba(0,0,0,0.4); margin-left:0; opacity: 1; -moz-animation:shadowSize 2s infinite ease-in-out; -webkit-animation:shadowSize 2s infinite ease-in-out; } @-moz-keyframes jump { 0% { top:100px;} 50% { top:25px;} 100% { top:100px;} } @-webkit-keyframes jump { 0% { top:100px;} 50% { top:25px;} 100% { top:100px;} } @-moz-keyframes shadowSize { 0% { width:200px; margin-left:0px; opacity:1; box-shadow:200px 0 10px rgba(0,0,0,0.7);} 50% { width:150px; margin-left:25px;opacity:0.3; box-shadow:200px 0 30px rgba(0,0,0,0.3);} 100% { width:200px; margin-left:0px; opacity:1; box-shadow:200px 0 10px rgba(0,0,0,0.7);} } @-webkit-keyframes shadowSize { 0% { width:200px; margin-left:0px; opacity:1; box-shadow:200px 0 10px rgba(0,0,0,0.7);} 50% { width:150px; margin-left:25px;opacity:0.3; box-shadow:200px 0 30px rgba(0,0,0,0.3);} 100% { width:200px; margin-left:0px; opacity:1; box-shadow:200px 0 10px rgba(0,0,0,0.7);} } </code></pre> <hr> <p>Now, with our dear jQ... just use a .png image for the shadow instead of my ugly <code>box-shadow</code> :)</p> <h2><em><a href="http://jsbin.com/amereb/1/edit">jQuery demo</a></em></h2> <pre><code>var li = 1; // a LoopIterations variable function loop(){ li = ++li%2; // reset evenly to '0' // results in 0, 1, 0, 1, 0, .... $('#shadow').animate({ width: !li ? 150:200 , marginLeft: !li ? 25:0 , opacity: !li ? 0.3:1 }, 2000); $('#box').animate({ top: !li ? 25 : 100 },2000, loop); // THIS 'loop' callback will recall the loop() function creating ... a loop :D } loop(); // start loop </code></pre> <p>To explain: On every odd iteration <code>li</code> will be set to <code>0</code>, and on every other to <code>1</code> thanks to <code>%</code> (Modulo operator).<br> <code>0</code> in Javascript can be represented as <code>false</code>, great for the use of a ternary operator that will check for two Boolean values e.g: <code>[true or false statement] ? [do this if true] : [do that if false] ;</code></p> <p><code>!li ? 150:200</code> means if <code>!li</code> (= 0 = is false) use <code>200</code> else use <code>150</code></p> <p>Additionally:</p> <pre><code>&lt;div id="box"&gt;&lt;/div&gt; &lt;div id="shadow"&gt;&lt;/div&gt; </code></pre> <p>and CSS:</p> <pre><code>#box{ position:absolute; top:100px; width:200px; height:200px; background:#6CB8E9; } #shadow{ position:absolute; top:310px; height:1px; background:rgba(0,0,0,0.26); width:200px; box-shadow:0 0 14px 2px #000; margin-left:0; opacity: 1; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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