2012-03-02 8 views
0

私は少し苦労していますが、私は、私はCSS/JavaScriptを使用して複製しようとしている効果に遭遇してきました...border fade/scale on click?

ウォッチhttp://www.youtube.com/watch?v=sXqXpwyBI1kと映画の中に、あなたはわかりますその際プレゼンタープレスボタンのどれかをクリックすると、白いボックスがズームしてフェードインしてすぐにフェードアウトします。

非常に微妙ですが、非常に効果的です。

このタイプのエフェクトの名前を知っている人もいれば、それを複製するコードにリンクしている人もいますか?

@Fabrizioに対する応答として、これは私が書いたコードです。ご覧のとおり、アニメーションを呼び出すと、「影」ボタンが幅0 /高さ0から始まり、目標の幅/高さに展開されます。幅/高さに...私はそれが0からリセットしない、「現在の」値をdecreated /増加し、再び開始思った= ...

-

別の奇妙なことは、私は+ =かを使用することはできませんです

<!doctype html> 
<html lang="en"> 
    <head> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
    <script> 
     $(function() { 
     $('.button').click(function() { 
      var shadow = $('<button class="button shadow">&nbsp;</button>'); 
      shadow.css({ 
      width : $(this).outerWidth() + 2, 
      height : $(this).outerHeight() + 2, 
      marginLeft : '-1px', 
      marginTop : '-1px', 
      opacity : 0 
      }); 

      $(this).before(shadow); 
      shadow.animate({ 
      opacity : 0.5, 
      marginLeft : '-=2', 
      marginTop : '-=2', 
      width : $(this).outerWidth() + 6, 
      height : $(this).outerHeight() + 6 
      }, 200); 
     }); 
     }); 
    </script> 
    <style> 
     * { margin: 0; padding: 0; } 
     body { padding: 50px; background: #333; } 
     .button { padding: 15px 25px; border: 0; cursor: pointer; font-weight: bold; } 
     .button.red { background: #FF0000; color: #FFFFFF; } 
     .button.shadow { background: transparent; display: block; position: absolute; border: solid 1px #FFFFFF; } 
    </style> 
    </head> 
    <body> 
    <button class="button red">Test</button> 
    </body> 
</html> 
+1

に、このいずれかを使用するつもりですが、あなたは、オンザフライでのdivを生成する位置絶対、クリックされたオブジェクトの座標を与え、次に作るためにアニメーションを使用することができます?jQueryのに見てきました私はそれをやったことはありませんが、jQueryの助けを借りて信じられないほど難しいとは思いません。 – Fabrizio

+0

私は、残念ながら私のラップトップはちょっと気分が悪く、何かをやろうとしていたときに、いくつかのテスト中に電源が切れました。アニメーション機能を使用して「ズーム」の代わりに幅、高さ、およびマージンを変更すると、「シャドウ」要素のサイズが0から幅/高さに変更されました。私はサンプルを投稿します。 ;) – Gavin

答えて

1

これは数分間で練習できたものです。

あなたはボーダーや色で遊ぶことができ、(たとえば、あなたがプラグインを使用しない限り、境界線の色をアニメーション化し、また

弾む効果を持つことができないアニメーションについての詳細はドキュメントをアニメーションのjQueryを参照してください。
$('.style_logo_position_extra_logo').mouseover(function(){ 
    $('<div/>') 
     .width($(this).outerWidth()) 
     .height($(this).outerHeight()) 
     .offset($(this).offset()) 
     .css({ 
      'border-width':'2px', 
      'border-style':'double', 
      'border-color':$(this).css('border-color'), 
      'position':'absolute', 
      'borderTopLeftRadius': $(this).css('borderTopLeftRadius'), 
      'borderTopRightRadius': $(this).css('borderTopRightRadius'), 
      'borderBottomLeftRadius': $(this).css('borderBottomLeftRadius'), 
      'borderBottomRightRadius': $(this).css('borderBottomRightRadius'), 
      'WebkitBorderTopLeftRadius': $(this).css('WebkitBorderTopLeftRadius'), 
      'WebkitBorderTopRightRadius': $(this).css('WebkitBorderTopRightRadius'), 
      'WebkitBorderBottomLeftRadius': $(this).css('WebkitBorderBottomLeftRadius'), 
      'WebkitBorderBottomRightRadius': $(this).css('WebkitBorderBottomRightRadius'), 
      'MozBorderRadius': $(this).css('MozBorderRadius') 
     }) 
     .appendTo('body') 
     .animate({ 
       'border-width':'6px', 
       'opacity':0.25, 
       'width':'+=6', //use even numbers if possible 
       'height':'+=6', 
       'left':'-=8', //-((+width/2) + (delta border) +1) = -((+6/2) + (6-2)+1) =-8 
       'top':'-=8', 
       'borderTopLeftRadius': '+=6', 
       'borderTopRightRadius': '+=6', 
       'borderBottomLeftRadius': '+=6', 
       'borderBottomRightRadius': '+=6', 
       'WebkitBorderTopLeftRadius': '+=6', 
       'WebkitBorderTopRightRadius': '+=6', 
       'WebkitBorderBottomLeftRadius': '+=6', 
       'WebkitBorderBottomRightRadius': '+=6', 
       'MozBorderRadius': '+=6' 
       },500, 'linear',function(){ 
        $(this).remove(); 
       }) 
     ; 
}) 

私は実際に私のサイト

+0

よく見えます。私はちょうどそれの周りにフィドルを持っています。私はビデオの作者が彼の秘密を分かち合うことができると思っています。もしそうなら、ここにも投稿します。 – Gavin

+0

私はFabrizioの反応を受け取り、それを少し簡略化し、フィーリングを作った:http://jsfiddle.net/bengundersen/T7u54/ – bgun