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.

            
              <span id="ball"></span>
<section>
  <span id="moveMe">Animation</span>
</section>
<section>
  <div class="transition">Transition</div>
</section>
<section>
  <div class="user-img"></div>
</section>

<!-- 
Common transforms:
transform: scale(2, 0.5);
transform: scaleX(2);
transform: scaleY(0.5);
transform: rotate(0.5turn);
transform: translateZ(2px);
transform: scale3d(2.5, 1.2, 0.3);
transform: scaleZ(0.3);
transform: rotate3d(1, 2.0, 3.0, 10deg);
transform: rotateX(10deg);
transform: rotateY(10deg);
transform: rotateZ(10deg);
transform: perspective(17px);
-->
            
          
!
            
              * {box-sizing: border-box;}
body { 
  font-family: arial;
  background: #444;
  color: #ccc;
}
section {
  width: 200px;
  display: block;
  position: absolute;
}
.transition {
  border: 5px solid #333;
  text-align: center;
  height: 5em;
  width: 6em;
  line-height: 4.5em;
  background: #666;
  opacity: .5;
  margin: 1em 1em 0 15em;
  // No commas between transforms
  transform: scale(1.2) ; // Transform simply applied
  transform-origin: center center; 
  transition:
    line-height .5s,
    color .5s, 
    width .5s, 
    height .5s, 
    background .5s, 
    transform .5s, // Looks at transform property and applies over time
    opacity .5s, 
    ease;
  &:hover {
    color: #444;
    opacity: .5;
    background: #ccc;
    width: 8em;
    height: 8em;
    line-height: 7em;
    // Something I want the element to do when hovered.
    // Without the transition property specifying it over time,
    // it would just be applied immediately
    transform: rotate(-5deg);
  }
}
// Transform triggered with a JS onclick event
#ball{
  border: 5px solid #333;
  border-radius: 50px;
  width: 50px;
  height: 50px;
  background: #666;
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 1s; 
}

// CSS Animations: create your animation
// use transforms for positioning, it creates a new
// stacking context and allows the browser to use the GPU
@keyframes play {
   0%   { transform: translate(50px, 0); opacity: 0; }
   25%  { transform: translate(100px, 0); }
   50%  { transform: translate(100px, 50px); opacity: 1;}
   75%  { transform: translate(100px, 0); }
   100% { transform: translate(50px, 0); opacity: 0;}
}
#moveMe {
  // call your animation by name
  animation: play 2s infinite;
  border: 5px solid #333;
  background: #666;
  padding: 1em;
  position: absolute;
}

//-----------------------------------------
// Animating clip-path
.user-img {
  transition: clip-path .5s ease, opacity .5s ease;
  clip-path: circle(10%);
  background-image: url(https://upload.wikimedia.org/wikipedia/commons/7/79/SNG.gif);
  background-postition:  left -30px top -50px;
  background-size: 100%;
  background-repeat: no-repeat;
  height: 200px;
  width: 200px;
  margin-left: 23em;
  opacity: .2;
  &:hover {
    clip-path: circle(50%);
    opacity: 1;
  }
}

            
          
!
            
              var b = document.getElementById('ball');
document.addEventListener('click', function(ev){
    b.style.transform = 'translateY('+(ev.clientY-25)+'px)';
    b.style.transform += 'translateX('+(ev.clientX-25)+'px)';
},false);    

            
          
!
999px
Loading ..................

Console