cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

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.

            
              -(10).times do |i|
  - if i % 2 == 0
    %div{ 'id' => 'dwaps-abeille', 'class' => "nerveuse delai-#{i+1}" }
  - else
    %div{ 'id' => 'dwaps-abeille', 'class' => "tranquille delai-#{i+1}" }
            
          
!
            
              @mixin anim($tailleAbeille)
{
	$posAilesStart: 0deg !global;
	$skewAiles: skew(35deg, 10deg) !global;
	$posPattesStart: 20deg !global;

	// 2 TYPES D'ABEILLES
	@include keyframes(animAbeilleNerveuse)
	{
		@include contentAnimAbeille(true, $tailleAbeille);
	}
	@include keyframes(animAbeilleTranquille)
	{
		@include contentAnimAbeille(false, $tailleAbeille);
	}
	

	@include keyframes(animTete)
	{
		@include contentAnimTete();
	}

	@include keyframes(animCorps)
	{
		@include contentAnimCorps();
	}

	@include keyframes(animPattesGauches)
	{
		@include contentAnimPattes(false, $posPattesStart);
	}

	@include keyframes(animPattesDroites)
	{
		@include contentAnimPattes(true, $posPattesStart);
	}

	@include keyframes(animAilesUpDown)
	{
		@include contentAnimAiles(false, $skewAiles, $posAilesStart);
	}

	@include keyframes(animAilesDownUp)
	{
		@include contentAnimAiles(true, $skewAiles, $posAilesStart);
	}
}

@mixin keyframes($name)
{
	@-webkit-keyframes #{$name}
	{
		$prefix: "-webkit-" !global;
		@content;
	}
	@-moz-keyframes #{$name}
	{
		$prefix: "-webkit-" !global;
		@content;
	}
	@-ms-keyframes #{$name}
	{
		$prefix: "-webkit-" !global;
		@content;
	}
	@-o-keyframes #{$name}
	{
		$prefix: "-webkit-" !global;
		@content;
	}
	@keyframes #{$name}
	{
		$prefix: "-webkit-" !global;
		@content;
	}
}

@mixin contentAnimAbeille($path1, $tailleAbeille)
{
	@if $path1
	{
		0% { 
			#{$prefix}transform: translate(12px, 50px) scale($tailleAbeille) rotateZ(45deg);
		}
		5% { 
			#{$prefix}transform: translate(12px, 50px) scale($tailleAbeille) rotateZ(45deg);
		}
		7% { 
			#{$prefix}transform: translate(112px, 200px) scale($tailleAbeille) rotateZ(5deg);
		}
		10% { 
			#{$prefix}transform: translate(112px, 200px) scale($tailleAbeille) rotateZ(5deg);
		}
		12% { 
			#{$prefix}transform: translate(150px, 120px) scale($tailleAbeille) rotateZ(-50deg);
		}
		15% { 
			#{$prefix}transform: translate(150px, 120px) scale($tailleAbeille) rotateZ(-50deg);
		}
		16% { 
			#{$prefix}transform: translate(158px, 150px) scale($tailleAbeille+0.2) rotateZ(45deg);
		}
		19% { 
			#{$prefix}transform: translate(158px, 150px) scale($tailleAbeille+0.1) rotateZ(45deg);
		}
		22% { 
			#{$prefix}transform: translate(10px, 200px) scale(-0.3+$tailleAbeille) rotateZ(90deg);
		}
		27% { 
			#{$prefix}transform: translate(10px, 200px) scale(-0.3+$tailleAbeille) rotateZ(90deg);
		}
		28% { 
			#{$prefix}transform: translate(88px, 98px) scale($tailleAbeille) rotateZ(2deg);
		}
		45% { 
			#{$prefix}transform: translate(88px, 98px) scale($tailleAbeille) rotateZ(5deg);
		}
		50% { 
			#{$prefix}transform: translate(12px, 50px) scale($tailleAbeille) rotateZ(-5deg);
		}
		53% { 
			#{$prefix}transform: translate(50px, 150px) scale($tailleAbeille) rotateZ(12deg);
		}
		55% { 
			#{$prefix}transform: translate(50px, 150px) scale($tailleAbeille) rotateZ(12deg);
		}
		56% { 
			#{$prefix}transform: translate(133px, 232px) scale($tailleAbeille+0.4) rotateZ(-13deg);
		}
		65% { 
			#{$prefix}transform: translate(133px, 232px) scale($tailleAbeille+0.4) rotateZ(-13deg);
		}
		67% { 
			#{$prefix}transform: translate(108px, 155px) scale($tailleAbeille+0.1) rotateZ(-56deg);
		}
		69% { 
			#{$prefix}transform: translate(108px, 155px) scale($tailleAbeille+0.1) rotateZ(-56deg);
		}
		70% { 
			#{$prefix}transform: translate(80px, 177px) scale(-0.4+$tailleAbeille) rotateZ(47deg);
		}
		74% { 
			#{$prefix}transform: translate(80px, 177px) scale(-0.4+$tailleAbeille) rotateZ(47deg);
		}
		76% { 
			#{$prefix}transform: translate(80px, 177px) scale(-0.9+$tailleAbeille) rotateZ(-13deg);
		}
		80% { 
			#{$prefix}transform: translate(80px, 177px) scale(-0.9+$tailleAbeille) rotateZ(-13deg);
		}
		82% { 
			#{$prefix}transform: translate(200px, 210px) scale($tailleAbeille+0.2) rotateZ(45deg);
		}
		86% { 
			#{$prefix}transform: translate(200px, 210px) scale($tailleAbeille+0.2) rotateZ(45deg);
		}
		88% { 
			#{$prefix}transform: translate(110px, 110px) scale(-0.1+$tailleAbeille) rotateZ(20deg);
		}
		91% { 
			#{$prefix}transform: translate(110px, 110px) scale(-0.1+$tailleAbeille) rotateZ(20deg);
		}
		92% { 
			#{$prefix}transform: translate(94px, 157px) scale($tailleAbeille) rotateZ(-16deg);
		}
		95% { 
			#{$prefix}transform: translate(94px, 157px) scale($tailleAbeille) rotateZ(-16deg);
		}
		97% { 
			#{$prefix}transform: translate(35px, 213px) scale($tailleAbeille) rotateZ(40deg);
		}
		100% { 
			#{$prefix}transform: translate(12px, 50px) scale($tailleAbeille) rotateZ(45deg);
		}
	}
	@else
	{
		0% { 
			#{$prefix}transform: translate(50px, 200px) scale($tailleAbeille) rotateZ(-27deg);
		}
		4% { 
			#{$prefix}transform: translate(50px, 200px) scale($tailleAbeille) rotateZ(-27deg);
		}
		7% { 
			#{$prefix}transform: translate(130px, 120px) scale($tailleAbeille+0.2) rotateZ(-14deg);
		}
		11% { 
			#{$prefix}transform: translate(130px, 120px) scale($tailleAbeille+0.2) rotateZ(-14deg);
		}
		15% { 
			#{$prefix}transform: translate(110px, 110px) scale($tailleAbeille) rotateZ(40deg);
		}
		24% { 
			#{$prefix}transform: translate(110px, 110px) scale($tailleAbeille) rotateZ(40deg);
		}
		26% { 
			#{$prefix}transform: translate(50px, 230px) scale($tailleAbeille+0.5) rotateZ(45deg);
		}
		29% { 
			#{$prefix}transform: translate(50px, 230px) scale($tailleAbeille+0.5) rotateZ(45deg);
		}
		35% { 
			#{$prefix}transform: translate(200px, 230px) scale($tailleAbeille) rotateZ(45deg);
		}
		47% { 
			#{$prefix}transform: translate(200px, 230px) scale($tailleAbeille) rotateZ(45deg);
		}
		50% { 
			#{$prefix}transform: translate(0px, 180px) scale(-0.1+$tailleAbeille) rotateZ(-56deg);
		}
		55% { 
			#{$prefix}transform: translate(0px, 180px) scale(-0.1+$tailleAbeille) rotateZ(-56deg);
		}
		60% { 
			#{$prefix}transform: translate(400px, 10px) scale($tailleAbeille+0.2) rotateZ(13deg);
		}
		63% { 
			#{$prefix}transform: translate(400px, 10px) scale($tailleAbeille+0.2) rotateZ(13deg);
		}
		68% { 
			#{$prefix}transform: translate(260px, 98px) scale($tailleAbeille+0.5) rotateZ(28deg);
		}
		72% { 
			#{$prefix}transform: translate(260px, 98px) scale($tailleAbeille+0.5) rotateZ(28deg);
		}
		75% { 
			#{$prefix}transform: translate(250px, 50px) scale($tailleAbeille) rotateZ(-15deg);
		}
		79%
		{
			#{$prefix}transform: translate(350px, 230px) scale($tailleAbeille+0.2) rotateZ(-15deg);
		}
		85% { 
			#{$prefix}transform: translate(120px, 80px) scale(-0.3+$tailleAbeille) rotateZ(-15deg);
		}
		97% { 
			#{$prefix}transform: translate(30px, 210px) scale($tailleAbeille) rotateZ(5deg);
		}
		100% { 
			#{$prefix}transform: translate(50px, 200px) scale($tailleAbeille) rotateZ(-27deg);
		}
	}
}

@mixin contentAnimTete()
{
	0% { 
		top: 2px;
	}
	50% { 
		top: 4px;
	}
	100% { 
		top: 2px;
	}
}

@mixin contentAnimCorps()
{
	0% { 
		#{$prefix}transform: scale(1);
	}
	50% { 
		#{$prefix}transform: scale(1.05);
	}
	100% { 
		#{$prefix}transform: scale(1);
	}
}

@mixin contentAnimPattes($droites, $posPattesStart)
{
	@if $droites
	{
		0% { 
			#{$prefix}transform: translate(0,0) skew(-$posPattesStart, $posPattesStart);
		}
		50% { 
			#{$prefix}transform: translate(1px,1px) skew(-3-$posPattesStart, 8+$posPattesStart);
		}
		70% { 
			#{$prefix}transform: translate(2px,2px) skew(-3-$posPattesStart, 8+$posPattesStart);
		}
		100% { 
			#{$prefix}transform: translate(0,0) skew(-$posPattesStart, $posPattesStart);
		}
	}
	@else
	{
		0% { 
			#{$prefix}transform: translate(0,0) skew($posPattesStart, -$posPattesStart);
		}
		50% { 
			#{$prefix}transform: translate(1px,1px) skew(-3+$posPattesStart, -8-$posPattesStart);
		}
		70% { 
			#{$prefix}transform: translate(2px,2px) skew(-3+$posPattesStart, -8-$posPattesStart);
		}
		100% { 
			#{$prefix}transform: translate(0,0) skew($posPattesStart, -$posPattesStart);
		}
	}
}

@mixin contentAnimAiles($downToUp, $skewAiles, $posAilesStart)
{
	@if $downToUp
	{
		0% { 
			#{$prefix}transform: rotate($posAilesStart) $skewAiles;
		}
		50% { 
			#{$prefix}transform: rotate(70+$posAilesStart) $skewAiles;
		}
		100% { 
			#{$prefix}transform: rotate($posAilesStart) $skewAiles;
		}
	}
	@else
	{
		0% { 
			#{$prefix}transform: rotate(-$posAilesStart) $skewAiles;
		}
		50% { 
			#{$prefix}transform: rotate(-70-$posAilesStart) $skewAiles;
		}
		100% { 
			#{$prefix}transform: rotate(-$posAilesStart) $skewAiles;
		}
	}
}


@mixin abeille($tailleAbeille, $dureeAnim:10, $delai:0)
{
	$wCorps: 30px;
	$hAnneaux: 10px;
	$wTete: 25px;
	$hTete: $wTete;
	$wYeux: 2px;
	$hYeux: $wYeux+6;
	$radius: 10px;

	width: $wCorps*4;
	position: absolute;
	z-index: 999999;

	@include anim($tailleAbeille);

	// $prefix est défini depuis l'animation !
	#{$prefix}transform: scale($tailleAbeille);


	&.nerveuse
	{
		#{$prefix}transform: translate(12px, 50px) scale($tailleAbeille) rotateZ(45deg);
    animation: animAbeilleNerveuse #{$dureeAnim}s #{$delai}s infinite alternate;
	}

	&.tranquille
	{
		#{$prefix}transform: translate(50px, 200px) scale($tailleAbeille) rotateZ(-27deg);
		animation: animAbeilleTranquille #{$dureeAnim}s #{$delai}s infinite alternate;
	}

	.commun
	{
		box-shadow: 5px 5px 15px gray;
		margin: auto;
	}

	.tete
	{
		@extend .commun;
		position: relative;
		animation: animTete 1s infinite;
		top: 2px;
		border-radius: 50%;
		background: #000;
		width: $wTete;
		height: $hTete;
		background: #000000; /* Old browsers */
		background: -moz-radial-gradient(center, ellipse cover, #000000 0%, #606060 100%); /* FF3.6-15 */
		background: -webkit-radial-gradient(center, ellipse cover, #000000 0%,#606060 100%); /* Chrome10-25,Safari5.1-6 */
		background: radial-gradient(ellipse at center, #000000 0%,#606060 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#606060',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */

		.blocs-before-after-yeux
		{
			display: block;
			position: absolute;
			background: white;
			top: 0;
			border-radius: 75%;
			border-top: 3px solid #000;
			border-bottom: 6px solid #000;
			border-left: 6px solid #000;
			border-right: 3px solid #000;
			height: $hYeux;
			width: $wYeux;
			content: "";
		}
		
		.yeux::before // droit
		{
			@extend .blocs-before-after-yeux;
			#{$prefix}transform: rotate(12deg);
			left: -1px;
		}
		
		.yeux::after // gauche
		{
			@extend .blocs-before-after-yeux;
			#{$prefix}transform: rotate(-12deg);
			right: -1px;
		}
	}

	.corps
	{
		@extend .commun;
		border-radius: $radius;
		margin: auto;
		width: $wCorps;
		animation: animCorps 1s infinite;

		span
		{
			display: block;
			margin: auto;
			height: $hAnneaux;
		}
		span:nth-child(odd) // Abdomen : anneaux noires
		{
			background: black;
			background: #160d0d; /* Old browsers */
			background: -moz-linear-gradient(left,  #160d0d 0%, #000000 48%, #fbffba 100%, #160d0d 100%); /* FF3.6-15 */
			background: -webkit-linear-gradient(left,  #160d0d 0%,#000000 48%,#fbffba 100%,#160d0d 100%); /* Chrome10-25,Safari5.1-6 */
			background: linear-gradient(to right,  #160d0d 0%,#000000 48%,#fbffba 100%,#160d0d 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
			filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#160d0d', endColorstr='#160d0d',GradientType=1 ); /* IE6-9 */

			width: $wCorps;
		}
		span:nth-child(even) // Abdomen : anneaux jaunes
		{
			background: yellow;
			background: #fff544; /* Old browsers */
			background: -moz-linear-gradient(left,  #fff544 0%, #e8dc00 48%, #fbffba 100%, #fff544 100%); /* FF3.6-15 */
			background: -webkit-linear-gradient(left,  #fff544 0%,#e8dc00 48%,#fbffba 100%,#fff544 100%); /* Chrome10-25,Safari5.1-6 */
			background: linear-gradient(to right,  #fff544 0%,#e8dc00 48%,#fbffba 100%,#fff544 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
			filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff544', endColorstr='#fff544',GradientType=1 ); /* IE6-9 */

			width: $wCorps+2;
			position: relative;
			right: 1px;
			border-radius: $radius;
		}
		.blocs-pattes
		{
			display: block;
			position: absolute;
			top: 6px;
			content: "";
			background: transparent;
			height: 20px;
			width: 12px;
			z-index: 500;
		}
		span:nth-child(even)::before // Pattes gauches
		{
			@extend .blocs-pattes;
			left: 0;
			border-top: 2px solid #000;
			border-left: 2px solid #000;
			#{$prefix}transform: rotate(-45deg) skew(-20deg, 20deg);
			animation: animPattesGauche 1s infinite;
			box-shadow: -2px -2px 3px #ddd;
		}
		span:nth-child(even)::after // Pattes droites
		{
			@extend .blocs-pattes;
			right: 0;
			border-top: 2px solid #000;
			border-right: 2px solid #000;
			#{$prefix}transform: rotate(45deg) skew(20deg, -20deg);
			animation: animPattesDroite 1s infinite;
			box-shadow: 2px 2px 3px #ddd;
		}
		span:first-child
		{
			border-top-left-radius: 2+$radius;
			border-top-right-radius: 2+$radius;
		}
		span:last-child
		{
			border-bottom-left-radius: $radius;
			border-bottom-right-radius: $radius;
		}
	}

	.ailes
	{
		position: relative;
		left: 3px;
		#{$prefix}transform: rotate(-5deg);
		z-index: -1;
	}
	.ailes:nth-child(odd)::before,
	.ailes:nth-child(even)::after
	{
		#{$prefix}transform: rotate($posAilesStart) skew(35deg, 10deg);
		animation: animAilesUpDown 150ms infinite linear;
	}
	.ailes:nth-child(odd)::after,
	.ailes:nth-child(even)::before
	{
		#{$prefix}transform: rotate(-$posAilesStart) skew(35deg, 10deg);
		animation: animAilesDownUp 150ms infinite linear;
	}
	.blocs-ailes
	{
		display: block;
		position: absolute;
		top: -45px;
		content: "";
		background: #ddd;
		border: 1px solid #222;
		width: 45px;
		height: 20px;
		border-radius: 50px;
	}
	.ailes::before // Ailes gauches
	{
		@extend .blocs-ailes;
		#{$prefix}transform-origin: 100%;
		left: 0;
	}

	.ailes::after // Ailes droites
	{
		@extend .blocs-ailes;
		#{$prefix}transform-origin: 0%;
		right: 0;
	}
}

// END MIXIN !!!

body
{
  background: lightblue;
  /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#7ab1db+1,c0d5db+13,c0d5db+19,d9f7f5+34,c0d5db+77,7ab1db+95,7db9e8+100 */
background: #7ab1db; /* Old browsers */
background: -moz-linear-gradient(-45deg, hsla(206,57%,67%,1) 1%, hsla(193,27%,81%,1) 13%, hsla(193,27%,81%,1) 19%, hsla(176,65%,91%,1) 34%, hsla(193,27%,81%,1) 77%, hsla(206,57%,67%,1) 95%, hsla(206,70%,70%,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, hsla(206,57%,67%,1) 1%,hsla(193,27%,81%,1) 13%,hsla(193,27%,81%,1) 19%,hsla(176,65%,91%,1) 34%,hsla(193,27%,81%,1) 77%,hsla(206,57%,67%,1) 95%,hsla(206,70%,70%,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, hsla(206,57%,67%,1) 1%,hsla(193,27%,81%,1) 13%,hsla(193,27%,81%,1) 19%,hsla(176,65%,91%,1) 34%,hsla(193,27%,81%,1) 77%,hsla(206,57%,67%,1) 95%,hsla(206,70%,70%,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7ab1db', endColorstr='#7db9e8',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}

#dwaps-abeille
{
	// @include abeille(0.2, 10s, 1s); // tailleAbeille, dureeAnim, delai
  
  @each $i in 1 2 3 4 5 6 7 8 9 10
  {
    &.delai-#{$i}
    {
      @if $i<5
      {
        @include abeille(0.2, $i+6, $i/2); 
      }
      @else
      {
        @include abeille(0.5, $i+4, $i/2); 
      }
    }
  }
}
            
          
!
            
              var DwapsAbeille = function() {
	this.init();
	this.creerAbeille();
};

DwapsAbeille.prototype = {
	init: function()
	{
		var THIS = this;
    
		// INITIALISATION DES VARIABLES
		this.dwapsAbeille = document.querySelectorAll("#dwaps-abeille");
		this.div, this.span;

		// SI UN ESSAIM EST DEMANDE...
		this.isNerveuse = false;
		this.dwapsAbeille.forEach(
			function(abeille)
			{
				THIS.creerEssaim(abeille.className);
			}
		);
	},
	creerAbeille: function(tag, isNerveuse)
	{
		var THIS = this;
		var els = tag ? [document.createElement("dwaps-abeille")] : this.dwapsAbeille;		

		els.forEach(
			function(abeille)
			{
				abeille.style.display = "block";

				// Tete				
				THIS.div = document.createElement("div");
				THIS.span = document.createElement("span");
				THIS.div.className = "tete";
				THIS.span.className = "yeux";
				THIS.div.appendChild(THIS.span);
				abeille.appendChild(THIS.div);

				// Corps
				THIS.div = document.createElement("div");
				THIS.div.className = "corps";
				for(var i in [1,2,3,4,5]) {
					THIS.span = document.createElement("span");
					THIS.div.appendChild(THIS.span);
				}
				abeille.appendChild(THIS.div);
				// Ailes
				for(var i in [1,2]) {
					THIS.div = document.createElement("div");
					THIS.div.className = "ailes";
					abeille.appendChild(THIS.div);
				}

				if(tag) 
				{
					abeille.className = isNerveuse ? "nerveuse" : "tranquille";
					document.body.appendChild(abeille);
				}
			}
		);
	},
	creerEssaim: function(isEssaim, nbAbeilles)
	{
		var THIS = this;
    
		if(typeof isEssaim === "string" && isEssaim.match("essaim"))
		{
			var clone, nbAbeilles = 10;

			this.dwapsAbeille[0].className += this.isNerveuse ? " nerveuse" : " tranquille";

			if(this.dwapsAbeille[0].className.match(/\d/))
			{
				var tab = this.dwapsAbeille[0].className.split(' ');
				tab.forEach(
					function(classe)
					{
						var nb = parseInt(classe);
						if(nb) nbAbeilles = nb;
					}
				);
			}

			nbAbeilles = parseInt(nbAbeilles);

			if(nbAbeilles > 20) nbAbeilles = 10;

			nbAbeilles--; // Celle qui est déjà dans le code compte pour 1 !
			this.creerEssaim(true, nbAbeilles);
		}
		else if(nbAbeilles > 0)
		{
			setTimeout(
				function()
				{
					nbAbeilles--;
					THIS.isNerveuse = !THIS.isNerveuse;
					THIS.creerAbeille(true, THIS.isNerveuse);
					THIS.creerEssaim(true, nbAbeilles);
				},
				Math.floor(Math.random()*1000)
			);
		}
	}
}

new DwapsAbeille();
            
          
!
999px
Loading ..................

Console