cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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.

            
              <h1>Experiments with HTML5</h1>
		<ul>
			<li><a href="https://www.html5rocks.com/en/tutorials/webcomponents/customelements/">Custom elements</a>. I want a custom-made syntactic html! I want my own tags with behaviour and style!
			<li><a href="https://www.html5rocks.com/en/tutorials/webcomponents/template/">Templates</a>. No more script type="template/x-handlebars-template" hack. Now we have Template html tag.
			<li><a href="https://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/">Shadow DOM</a>. Each tile have its own CSS. And the page CSS does not affect the tiles. See the backgounds!
			<li><a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">Flexbox</a>. I do not want space between the tiles!
			<li><a href="https://greensock.com/gsap">GSAP</a>. Because I want some animations.
		</ul>

		<template id="tile">
			<style> 
				div {
					border: 3px solid black; 
					width: 256px; height: 256px; 
					background-color: red; }
			</style>
			<div><img src="https://falicov.soluciones3f.com.ar/assets/texture.png" /></div>
		</template>

		<div id="container">
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/spade.png"></s3f-tile>
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/heart.png"></s3f-tile>
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/club.png"></s3f-tile>
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/diamond.png"></s3f-tile>
		</div>
            
          
!
            
              div { background-color: blue !important; }
			#container { 
				display: flex; flex-flow: row wrap; 
				width: 524px; margin: 0 auto;
			}
            
          
!
            
              var S3fTileProto = Object.create(HTMLElement.prototype);

S3fTileProto.spin = function() {
	// Initiate a spin when it is spinning does not look right.	
	if(this.isSpinning == true) return;
	this.isSpinning = true;

	var $element = $(this.shadowRoot).find("div");
	var $img = $(this.shadowRoot).find("img");
	
	var showFront = function() { $img.attr("src", this.attr("back-image")); }.bind($(this));
	var showBack = function() { $img.attr("src", "https://falicov.soluciones3f.com.ar/assets/texture.png"); };

	TweenLite.set($element, {transformPerspective:500});
	new TimelineLite()
		.fromTo($element, 1, {rotationY: "0deg"}, { rotationY: "90deg", ease: Power1.easeIn, onComplete: showFront })
		.to($element, 1, { rotationY: "180deg", ease: Power1.easeOut })
		.to($element, 1, { rotationY: "270deg", ease: Power1.easeIn, onComplete: showBack })
		.to($element, 1, { rotationY: "360deg", ease: Power1.easeOut, onComplete: function() { this.isSpinning = false }.bind(this) })
		.play();
};

S3fTileProto.createdCallback = function() {
	this.addEventListener('click', this.spin);

	var clone = document.importNode($('#tile')[0].content, true);
	this.createShadowRoot().appendChild(clone);
}

document.registerElement("s3f-tile", { prototype: S3fTileProto });
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console