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 Daily CSS Images :: 28   - Cogs
  small By Kim Doberstein

#container
  #cogs
    .cog
      .teeth
      .teeth
      .teeth
      .teeth
    .cog
      .teeth
      .teeth
      .teeth
      .teeth


.description
  h2 What  did I learn?
  p Watching gears is overly relaxing  :-)
  p Another example of a simple animation.  Good reminder that you need to specify the starting position (rotation in this case) in the keyframe even if you have already set it.
  
            
          
!
            
              /****************** DESCRIPTION ****************/
h1{
  font-family: 'Pacifico', cursive;
  color:#333;
  font-size:5vw;
  small{
    display:block;
    margin-left:10%;
    color:#666;
  }
}

.description{
  font-family: 'Open Sans', sans-serif;
}
/************************************************/

#container{
  border:1px solid #000;
  position: relative;
  margin: auto;
  width: 75%;
}
/******************* VARS **********************/
$heightToWidthRatio:0.5; 
$bgColor:#F1E8E3;
$cogColor:#bbb;

/******************* MIXINS **********************/
@mixin square($widthSize, $heightToWidthRatio){
  /* for example 5/4 ratio would be 1.25 */
  height:calc(#{$widthSize}/#{$heightToWidthRatio});
  width:$widthSize;
}
@mixin circle($radiusWidth, $heightToWidthRatio){
  @include square($radiusWidth, $heightToWidthRatio);
  border-radius:50%;
}
@mixin size($widthPercent, $heightPercent){
  width:$widthPercent;
  height:$heightPercent;
}

@mixin position($left, $top){
  left:$left;
  top:$top;
}
@mixin sizePosition($widthPercent, $heightPercent,$left, $top){
  @include size($widthPercent, $heightPercent);
  @include position($left, $top);
}

/******************* MY IMAGE **********************/


#cogs{
  background-color:$bgColor;
  width: 100%;
  padding-bottom:calc(#{$heightToWidthRatio}*100%);
  position:relative;
  *, *:before, *:after{
    position:absolute;
    content:'';
    z-index:200;
  }
  @keyframes rotate {100% {transform: rotateZ(360deg);}}
  @keyframes rotate2 { 0% {transform: rotateZ(22deg);}100% {transform: rotateZ(-338deg);}}
  .cog{
    @include circle(33%, $heightToWidthRatio);
    background-color:$cogColor;
    top:15%;
    
    transform-origin: 50% 50%;
    &:nth-child(1){left:12%;  animation: rotate 5s infinite linear;}
    &:nth-child(2){right:12%; transform:rotateZ(22deg);  animation: rotate2 5s infinite linear;}
   
    &:after{
      @include circle(20%, 1);
      background-color:#666;
      left:40%;
      top:40%;
    }
    .teeth{
      width:75%;
      height:75%;
      top:-25%;
      left:50%;
      transform-origin: 0% 100%;
      &:before,&:after{
        background-color:$cogColor;
        width:30%;
        height:40%;
        left:-15%;
        top:5%;
        border-radius:20%;
      }
      &:after{
        transform-origin: 50% 240%;
        transform:rotate(45deg);
      }
      
      &:nth-child(1){}
      &:nth-child(2){transform:rotate(90deg)}
      &:nth-child(3){transform:rotate(180deg)}
      &:nth-child(4){transform:rotate(270deg)}
      
    }
  }
}

            
          
!
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