Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
<svg viewBox="0 0 180 120" preserveAspectRatio="none">
  <path d="M59.7890625,26.890625 L16.1679688,105.132812 L100.671875,105.132812 L59.7890625,26.890625 Z"></path>
  <desc>Created with Snap</desc>
  <defs></defs>
</svg>
<br>
<a href="#" class="btn test1">Ribbon</a>
<a href="#" class="btn test2">★</a>
<a href="#" class="btn test3">▲</a>
</div>
              
            
!

CSS

              
                svg{
  width: 260px;
  height: 180px;
  margin-left: 30px;
}

a{
  margin-right: 20px;
}

              
            
!

JS

              
                // アニメのパラメータ
var speed = 330,easing = mina.backout;

// リボンのパス
var ribbonPath = 'M17.8076546,97.9872742 L17.8076546,69.5996094 L17.8076546,33.9765625 L17.8076546,9.97851562 L57.7021858,42.5039062 L97.5967171,9.97851562 L97.5967171,39.2888832 L97.5967171,65.8574219 L97.596718,97.9872742 L55.4443733,97.9872742 L17.8076546,97.9872742 Z';
// ★のパス
var starPath = 'M33.3130194,97.9872772 L38.0278132,68.2204159 L18.0556263,47.884842 L45.6565097,41.4338687 L58,9.97851562 L70.3434903,39.2888833 L97.9443737,42.5821465 L77.9721868,69.5460898 L82.6869806,106.567219 L58,86.5107422 L33.3130194,97.9872772 Z';
// ▲のパス
var trianglePath = 'M20.3632809,97.9872742 L32.9609372,68.220417 L38.0278134,53.9828949 L45.3906247,39.2888832 L58,9.97851562 L70.3434903,39.2888833 L77.9721874,53.9828949 L85.6132819,68.220417 L100.152344,97.9872742 L57.9999997,97.9872742 L20.3632809,97.9872742 Z';

// 対象のsvgをキャッシュ
var s = Snap( $('svg')[0] );
// svgタグの中のパス部分
var path = s.select( 'path' );


$('.btn').on('click',function(e){
  e.preventDefault();
  e.stopPropagation();
  
  var name = $(e.target).attr('class');

  switch(name){
    case 'btn test1':
      // 変更実行
      path.animate( { 'path' : ribbonPath }, speed, easing );
      break;
    case 'btn test2':
      path.animate( { 'path' : starPath }, speed, easing );
      break;
    case 'btn test3':
      path.animate( { 'path' : trianglePath }, speed, easing );
      break;
  }
});
              
            
!
999px

Console