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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              <div></div>

<a href="https://codepen.io/danwilson/pen/BRdJVZ" target="_blank">See the full accordion</a>
            
          
!
            
              /*keyboard side*/
div {
  background:
    var(--shine),
    var(--shine),
    var(--button-key1, var(--button)),
    var(--button-key2, var(--button)),
    var(--button-key3, var(--button)),
    var(--the-black-keys),
    var(--white-keys),
    var(--keyboard-base);
  background-repeat: no-repeat;
  
  background-position:
    80% 0,
    85% 0,
    var(--button-key-x) var(--button-key1-y),
    var(--button-key-x) var(--button-key2-y),
    var(--button-key-x) var(--button-key3-y),
    var(--black-keys-position),
    var(--white-keys-position),
    0 0;
  
  background-size:
    1px 100%,
    2px 100%,
    100%,
    100%,
    100%,
    var(--black-keys-size),
    var(--white-keys-size),
    100%;
  
  width: calc(var(--bellow-width) * .36);
  height: calc(var(--height) + 5vmin);
  border-radius: 4vmin 1vmin 1vmin 4vmin;
  border: 0vmin solid var(--color2);
  
  box-shadow: inset 1vmin 0px 0 1vmin rgba(235,235,239,.2);
  
  color: rgba(0,0,0,0);
  font-size: 4vmin;
}

div {
  --color1: hsl(196, 50%, 50%);
  --color1alt: hsl(196, 50%, 33%);
  --color1alta: hsl(196, 50%, 73%);
  --color2: hsl(356, 70%, 50%);
  --color2alt: hsl(356, 70%, 40%);
  --color2alta: hsl(356, 70%, 80%);
  --color3: hsl(33, 80%, 60%);
  --color3alt: hsl(43, 80%, 50%);
  --white: #eaeaef;
  --white-between: hsla(0,0%,0%,.2);
  --black: var(--color1alt);
  
  --height: 40vmin;
  --bellow-y: 1vmin;
  --bellow-y-less: 39vmin;
  --bellow-width: 50vmin;
  
  --button-dim: 1.4vmin;
  --button: radial-gradient(circle, var(--color1) var(--button-dim), transparent var(--button-dim));
  
  --button-key-x: 5.5vmin;
  --button-key1-y: -6vmin;
  --button-key2-y: 0vmin;
  --button-key3-y: 6vmin;
   
  --shine: linear-gradient(to bottom, transparent 11.5%, var(--color2) 11.5%, var(--color2) 29.5%, transparent 29.5%, transparent 70.5%, var(--color2) 70.5%, var(--color2) 88.5%, transparent 88.5%);
  
  --the-black-keys: 
    linear-gradient(
      to bottom,
      transparent 3.5%,
      var(--black1, var(--black)) 3.5%,
      var(--black1, var(--black)) 6.5%,
      transparent 6.5%,
      transparent 8.5%,
      var(--black2, var(--black)) 8.5%,
      var(--black2, var(--black)) 11.5%,
      transparent 11.5%,
      transparent 13.5%,
      var(--black3, var(--black)) 13.5%,
      var(--black3, var(--black)) 16.5%,
      transparent 16.5%,
      
      transparent 23.5%,
      var(--black4, var(--black)) 23.5%,
      var(--black4, var(--black)) 26.5%,
      transparent 26.5%,
      transparent 28.5%,
      var(--black5, var(--black)) 28.5%,
      var(--black5, var(--black)) 31.5%,
      transparent 31.5%,
      
      transparent 38.5%,
      var(--black6, var(--black)) 38.5%,
      var(--black6, var(--black)) 41.5%,
      transparent 41.5%,
      transparent 43.5%,
      var(--black7, var(--black)) 43.5%,
      var(--black7, var(--black)) 46.5%,
      transparent 46.5%,
      transparent 48.5%,
      var(--black8, var(--black)) 48.5%,
      var(--black8, var(--black)) 51.5%,
      transparent 51.5%,
      
      transparent 58.5%,
      var(--black9, var(--black)) 58.5%,
      var(--black9, var(--black)) 61.5%,
      transparent 61.5%,
      transparent 63.5%,
      var(--black10, var(--black)) 63.5%,
      var(--black10, var(--black)) 66.5%,
      transparent 66.5%,
      
      
      transparent 73.5%,
      var(--black11, var(--black)) 73.5%,
      var(--black11, var(--black)) 76.5%,
      transparent 76.5%,
      transparent 78.5%,
      var(--black12, var(--black)) 78.5%,
      var(--black12, var(--black)) 81.5%,
      transparent 81.5%,
      transparent 83.5%,
      var(--black13, var(--black)) 83.5%,
      var(--black13, var(--black)) 86.5%,
      transparent 86.5%,
      
      transparent 93.5%,
      var(--black14, var(--black)) 93.5%,
      var(--black14, var(--black)) 96.5%,
      transparent 96.5%
    );
  
  /* If not animating, the keys can be done with a repeating linear gradient, breaking it out explicity (a few lines down) allows us more animation options 
  --white-keys: repeating-linear-gradient(to bottom, 
      var(--white-between) 0%,
      var(--white-between) 0.4%,
      var(--white) 0.4%,
      var(--white) 5%);
  */
  
  --white-keys: linear-gradient(to bottom, 
      var(--white-between) 0%,
      var(--white-between) 0.4%,
      var(--white1, var(--white)) 0.4%,
      var(--white1, var(--white)) 5%, 
      var(--white-between) 5%,
      var(--white-between) 5.4%,
      var(--white2, var(--white)) 5.4%,
      var(--white2, var(--white)) 10%, 
      var(--white-between) 10%,
      var(--white-between) 10.4%,
      var(--white3, var(--white)) 10.4%,
      var(--white3, var(--white)) 15%, 
      var(--white-between) 15%,
      var(--white-between) 15.4%,
      var(--white4, var(--white)) 15.4%,
      var(--white4, var(--white)) 20%, 
      var(--white-between) 20%,
      var(--white-between) 20.4%,
      var(--white5, var(--white)) 20.4%,
      var(--white5, var(--white)) 25%, 
      var(--white-between) 25%,
      var(--white-between) 25.4%,
      var(--white6, var(--white)) 25.4%,
      var(--white6, var(--white)) 30%, 
      var(--white-between) 30%,
      var(--white-between) 30.4%,
      var(--white7, var(--white)) 30.4%,
      var(--white7, var(--white)) 35%, 
      var(--white-between) 35%,
      var(--white-between) 35.4%,
      var(--white8, var(--white)) 35.4%,
      var(--white8, var(--white)) 40%, 
      var(--white-between) 40%,
      var(--white-between) 40.4%,
      var(--white9, var(--white)) 40.4%,
      var(--white9, var(--white)) 45%, 
      var(--white-between) 45%,
      var(--white-between) 45.4%,
      var(--white10, var(--white)) 45.4%,
      var(--white10, var(--white)) 50%, 
      var(--white-between) 50%,
      var(--white-between) 50.4%,
      var(--white11, var(--white)) 50.4%,
      var(--white11, var(--white)) 55%, 
      var(--white-between) 55%,
      var(--white-between) 55.4%,
      var(--white12, var(--white)) 55.4%,
      var(--white12, var(--white)) 60%, 
      var(--white-between) 60%,
      var(--white-between) 60.4%,
      var(--white13, var(--white)) 60.4%,
      var(--white13, var(--white)) 65%, 
      var(--white-between) 65%,
      var(--white-between) 65.4%,
      var(--white14, var(--white)) 65.4%,
      var(--white14, var(--white)) 70%, 
      var(--white-between) 70%,
      var(--white-between) 70.4%,
      var(--white15, var(--white)) 70.4%,
      var(--white15, var(--white)) 75%, 
      var(--white-between) 75%,
      var(--white-between) 75.4%,
      var(--white16, var(--white)) 75.4%,
      var(--white16, var(--white)) 80%, 
      var(--white-between) 80%,
      var(--white-between) 80.4%,
      var(--white17, var(--white)) 80.4%,
      var(--white17, var(--white)) 85%, 
      var(--white-between) 85%,
      var(--white-between) 85.4%,
      var(--white18, var(--white)) 85.4%,
      var(--white18, var(--white)) 90%, 
      var(--white-between) 90%,
      var(--white-between) 90.4%,
      var(--white19, var(--white)) 90.4%,
      var(--white19, var(--white)) 95%, 
      var(--white-between) 95%,
      var(--white-between) 95.4%,
      var(--white20, var(--white)) 95.4%,
      var(--white20, var(--white)) 100%);
  
  --keyboard-base: linear-gradient(to right, var(--color3alt), var(--color3alt));
  
  --black-keys-position: 45% center;
  --black-keys-size: 36% 84%;
  --white-keys-position: left center;
  --white-keys-size: 66% 84%;
}













body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
  background: hsl(33, 80%, 9%);
}
a {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2vmin;
  background: hsla(43, 0%, 0%, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, --apple-system, 'Segoe UI', sans-serif;
  color: #fafaff;
  
  display: none;
}



            
          
!
            
              //Uncomment the following to show the `requestAnimationFrame` animation

/*
var div = document.querySelector('div');
var buttons = {};
const numBlackKeys = 14;
const numWhiteKeys = 20;

function pressKeys() {
  var now = Date.now();
  var blackKey = Math.ceil((now % 2800) / 200);
  var whiteKey = Math.ceil((now % 4000) / 200);
  div.style.setProperty('--black'+blackKey, 'var(--color2alt)');
  div.style.setProperty('--black'+((blackKey - 1) || numBlackKeys), 'var(--black)');
  div.style.setProperty('--white'+whiteKey, 'var(--color1alta)');
  div.style.setProperty('--white'+((whiteKey - 1) || numWhiteKeys), 'var(--white)');
  requestAnimationFrame(pressKeys);
}
pressKeys();
/**/
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console