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.

            
              <button class="actual">Not Correct</button>
<button class="expected">Expected</button>
<button class="via-itp">Independent Transforms</button>
<button class="via-variables">CSS Variables</button>
            
          
!
            
              
.actual, .expected {
  transform: translateY(-150%);
}

/* will (perhaps unintentionally) override the original translate */
.actual:hover {
  transform: scale(.8);
}
/* will (perhaps unintentionally) override the original translate and scale */
.actual:active {
  transform: rotate(-5deg);
}


/* explicitly restates each previous transform function and works as intended */
.expected:hover {
  transform: translateY(-150%) scale(.8);
}
.expected:active {
  transform: translateY(-150%) scale(1) rotate(-5deg);
}
.expected:hover:active {
  transform: translateY(-150%) scale(.8) rotate(-5deg);
}

/* will have similar experience to expected, but organized differently */
.via-variables {
  --y: -150%;
  --scale: 1;
  --rotation: 0deg;
  
  transform: translateY(var(--y)) scale(var(--scale)) rotate(var(--rotation));
}
.via-variables:hover {
  --scale: .8;
}
.via-variables:active {
  --rotation: -5deg;
}

.via-itp {
  
  transition: 
    translate 125ms ease-out,
    scale 125ms ease-out,
    rotate 125ms ease-out;
  translate: 0 -150%;
}
.via-itp:hover {
  scale: .8 .8;
}
.via-itp:active {
  rotate: -5deg;
}




button {
  border: 2px solid hsl(140, 80%, 70%);
  border-radius: 5vmin;
  appearance: none;
  height: 3rem;
  padding: 0 1rem;
  background: hsl(140, 80%, 70%);
  margin: 1rem;
  
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  
  transition: transform 125ms ease-out;
}

body {
  height: 100vh;
  background: linear-gradient(to bottom,
    hsl(220, 12%, 12%) calc(50vh - 1px),
    hsl(220, 12%, 32%) calc(50vh - 1px),
    hsl(220, 12%, 32%) calc(50vh + 1px),
    hsl(220, 12%, 12%) calc(50vh + 1px));
  display: flex;
  justify-content: center;
  align-items: center;
}

button:focus {
  outline: 0; /* just for demo clarity for hover v active */
}



/*
.via-variables,
.via-itp {
  background: transparent;
  color: transparent;
}
.active.via-variables,
.active.via-itp {
  background: hsl(140, 80%, 70%);
  color: black;
}
*/
            
          
!
            
              document.querySelector('.via-itp').addEventListener('click', add);
document.querySelector('.via-variables').addEventListener('click', add);

function add(e) {
  e.currentTarget.classList.add('active')
}
            
          
!
999px
Loading ..................

Console