Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- Check out the dribble -->
<!-- https://dribbble.com/shots/5923128-Pop-Up-Animation-adobe-Xd -->
<!-- <div class="options">
  
</div> -->
<div class="options">
    <div class="option" onclick="setView('visa-selection')">
       <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" data-view="mastercard-selection"><circle stroke="#000" cx="10" cy="10" r="9" fill="none" fill-rule="evenodd"/></svg>
      <svg data-view="visa-selection" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle stroke="#7ED321" fill="#7ED321" cx="10" cy="10" r="9"/><path stroke="#FFF" d="M5 9l4 5 7-7"/></g></svg>
      <svg width="48" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M41.591 5.376l-1.995 5.893h3.152l-1.157-5.893m2.699-4.244l3.072 15.718h-3.508l-.491-2.337c-1.542 0-3.062-.006-4.581.012-.128.002-.261.165-.38.269-.042.038-.05.123-.073.187-.238.627-.32 1.503-.756 1.814-.448.319-1.242.09-1.884.095-.621.004-1.242 0-1.97 0 .083-.253.14-.457.217-.652 1.783-4.548 3.58-9.089 5.341-13.646.397-1.027 1.024-1.507 2.06-1.468.963.036 1.928.008 2.953.008M9.799 10.36l.315 1.436 3.427-9.264c.518-1.4.518-1.4 1.914-1.4h2.595c-.364.948-.701 1.843-1.05 2.732-1.632 4.165-3.272 8.326-4.893 12.496-.154.395-.339.555-.752.542-1.028-.034-2.058.005-3.086-.028-.172-.006-.45-.195-.49-.353-.456-1.825-.876-3.661-1.305-5.494L5.952 8.85l-.528-2.194.004.01-.284-1.116-.073-.274c-.007-.28-.03-.56-.017-.84.035-.807-.433-1.202-1.042-1.489l.004.002-.254-.147h.002a462.927 462.927 0 01-.259-.133c-.258-.178-.497-.412-.778-.52-.658-.256-1.337-.451-2.007-.67.122-.205.26-.301.398-.305a35.312 35.312 0 011.897-.006c1.192.03 2.384.084 3.576.12.859.027 1.501.628 1.692 1.53.127.6.325 1.184.491 1.775l.001.02c-.024.201-.102.415-.064.602.35 1.718.722 3.43 1.088 5.145" fill="#2B2F6C"/><path d="M34.575 1.556l-.615 3.077c-1.23-.163-2.4-.32-3.57-.47a1.36 1.36 0 00-.384.026c-.777.127-1.378.584-1.45 1.154-.095.76.45 1.09.94 1.409.657.426 1.353.784 2.017 1.2 1.429.897 2.458 2.092 2.364 4.002-.098 2.012-1.075 3.427-2.738 4.313-1.692.9-3.505.993-5.334.762-.923-.117-1.828-.393-2.819-.615l.671-3.46c.84.267 1.633.636 2.456.747.855.115 1.748.052 2.607-.072.587-.085 1.074-.507 1.157-1.213.078-.66-.322-1.07-.8-1.37-.716-.454-1.469-.845-2.179-1.31-1.381-.902-2.422-2.048-2.306-3.958.118-1.932 1.122-3.208 2.663-4.064 1.979-1.1 4.843-1.163 7.32-.158M19.7 1.165h3.813c-1.05 5.255-2.093 10.462-3.14 15.695h-3.808L19.7 1.165" fill="#2B306C"/><path d="M8.774 4.593c-.166-.591-.364-1.174-.491-1.775-.191-.902-.833-1.503-1.692-1.53-1.192-.036-2.384-.09-3.576-.12a35.17 35.17 0 00-1.897.006c-.139.004-.276.1-.398.305.67.219 1.349.414 2.007.67.281.108.52.342.778.52-1.018-.336-2.038-.666-3.052-1.015C.34 1.615.26 1.47.166 1.374c.106-.082.212-.236.319-.236 2.186-.006 4.373-.03 6.558.033.66.019 1.158.528 1.34 1.214.189.718.265 1.47.391 2.208M9.799 10.36c-.366-1.714-.737-3.427-1.088-5.145-.038-.187.04-.4.064-.602.305 1.647.612 3.294.914 4.942.048.266.074.536.11.805M4.012 2.947c.61.287 1.077.682 1.042 1.489-.012.279.01.56.017.84-.123-.435-.199-.893-.38-1.298-.168-.374-.448-.69-.679-1.03M5.952 8.85l.522 2.177-.522-2.177M5.424 6.656l.528 2.194-.528-2.194M5.144 5.55l.5 1.115-.5-1.115M3.501 2.667" fill="#363765"/><path d="M3.762 2.802l.5.5-.5-.5" fill="#363765"/><path d="M41.591 5.376l1.157 5.893h-3.152l1.995-5.893" fill="#F2F2F5"/></g></svg>
    <span class="c-number"> * * 4 6 </span>
  </div>
   <div class="option" onclick="setView('mastercard-selection')">
       <svg data-view="visa-selection"  width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle stroke="#000" cx="10" cy="10" r="9" fill="none" fill-rule="evenodd"/></svg>
     <svg data-view="mastercard-selection" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle stroke="#7ED321" fill="#7ED321" cx="10" cy="10" r="9"/><path stroke="#FFF" d="M5 9l4 5 7-7"/></g></svg>
      <svg width="48" height="28" viewBox="0 0 131.39 86.9" preserveAspectRatio="none"><defs><style>.e{fill:#f79e1b}</style></defs><path fill="#ff5f00" d="M48.37 15.14h34.66v56.61H48.37z"/><path d="M51.94 43.45a35.94 35.94 0 0 1 13.75-28.3 36 36 0 1 0 0 56.61 35.94 35.94 0 0 1-13.75-28.31z" fill="#eb001b"/><path class="e" d="M120.5 65.76V64.6h.5v-.24h-1.19v.24h.47v1.16zm2.31 0v-1.4h-.36l-.42 1-.42-1h-.36v1.4h.26V64.7l.39.91h.27l.39-.91v1.06zM123.94 43.45a36 36 0 0 1-58.25 28.3 36 36 0 0 0 0-56.61 36 36 0 0 1 58.25 28.3z"/></svg>
    <span class="c-number"> * * 9 1 </span>
  </div>
</div>
<div class="card" onclick="setOptionsDisplay()" role="button">
  <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle stroke="#7ED321" fill="#7ED321" cx="10" cy="10" r="9"/><path stroke="#FFF" d="M5 9l4 5 7-7"/></g></svg>
 <div>
    <svg data-view="visa-selection" width="48" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M41.591 5.376l-1.995 5.893h3.152l-1.157-5.893m2.699-4.244l3.072 15.718h-3.508l-.491-2.337c-1.542 0-3.062-.006-4.581.012-.128.002-.261.165-.38.269-.042.038-.05.123-.073.187-.238.627-.32 1.503-.756 1.814-.448.319-1.242.09-1.884.095-.621.004-1.242 0-1.97 0 .083-.253.14-.457.217-.652 1.783-4.548 3.58-9.089 5.341-13.646.397-1.027 1.024-1.507 2.06-1.468.963.036 1.928.008 2.953.008M9.799 10.36l.315 1.436 3.427-9.264c.518-1.4.518-1.4 1.914-1.4h2.595c-.364.948-.701 1.843-1.05 2.732-1.632 4.165-3.272 8.326-4.893 12.496-.154.395-.339.555-.752.542-1.028-.034-2.058.005-3.086-.028-.172-.006-.45-.195-.49-.353-.456-1.825-.876-3.661-1.305-5.494L5.952 8.85l-.528-2.194.004.01-.284-1.116-.073-.274c-.007-.28-.03-.56-.017-.84.035-.807-.433-1.202-1.042-1.489l.004.002-.254-.147h.002a462.927 462.927 0 01-.259-.133c-.258-.178-.497-.412-.778-.52-.658-.256-1.337-.451-2.007-.67.122-.205.26-.301.398-.305a35.312 35.312 0 011.897-.006c1.192.03 2.384.084 3.576.12.859.027 1.501.628 1.692 1.53.127.6.325 1.184.491 1.775l.001.02c-.024.201-.102.415-.064.602.35 1.718.722 3.43 1.088 5.145" fill="#2B2F6C"/><path d="M34.575 1.556l-.615 3.077c-1.23-.163-2.4-.32-3.57-.47a1.36 1.36 0 00-.384.026c-.777.127-1.378.584-1.45 1.154-.095.76.45 1.09.94 1.409.657.426 1.353.784 2.017 1.2 1.429.897 2.458 2.092 2.364 4.002-.098 2.012-1.075 3.427-2.738 4.313-1.692.9-3.505.993-5.334.762-.923-.117-1.828-.393-2.819-.615l.671-3.46c.84.267 1.633.636 2.456.747.855.115 1.748.052 2.607-.072.587-.085 1.074-.507 1.157-1.213.078-.66-.322-1.07-.8-1.37-.716-.454-1.469-.845-2.179-1.31-1.381-.902-2.422-2.048-2.306-3.958.118-1.932 1.122-3.208 2.663-4.064 1.979-1.1 4.843-1.163 7.32-.158M19.7 1.165h3.813c-1.05 5.255-2.093 10.462-3.14 15.695h-3.808L19.7 1.165" fill="#2B306C"/><path d="M8.774 4.593c-.166-.591-.364-1.174-.491-1.775-.191-.902-.833-1.503-1.692-1.53-1.192-.036-2.384-.09-3.576-.12a35.17 35.17 0 00-1.897.006c-.139.004-.276.1-.398.305.67.219 1.349.414 2.007.67.281.108.52.342.778.52-1.018-.336-2.038-.666-3.052-1.015C.34 1.615.26 1.47.166 1.374c.106-.082.212-.236.319-.236 2.186-.006 4.373-.03 6.558.033.66.019 1.158.528 1.34 1.214.189.718.265 1.47.391 2.208M9.799 10.36c-.366-1.714-.737-3.427-1.088-5.145-.038-.187.04-.4.064-.602.305 1.647.612 3.294.914 4.942.048.266.074.536.11.805M4.012 2.947c.61.287 1.077.682 1.042 1.489-.012.279.01.56.017.84-.123-.435-.199-.893-.38-1.298-.168-.374-.448-.69-.679-1.03M5.952 8.85l.522 2.177-.522-2.177M5.424 6.656l.528 2.194-.528-2.194M5.144 5.55l.5 1.115-.5-1.115M3.501 2.667" fill="#363765"/><path d="M3.762 2.802l.5.5-.5-.5" fill="#363765"/><path d="M41.591 5.376l1.157 5.893h-3.152l1.995-5.893" fill="#F2F2F5"/></g></svg>
    <svg data-view="mastercard-selection" width="48" height="28" viewBox="0 0 131.39 86.9" preserveAspectRatio="none"><defs><style>.e{fill:#f79e1b}</style></defs><path fill="#ff5f00" d="M48.37 15.14h34.66v56.61H48.37z"/><path d="M51.94 43.45a35.94 35.94 0 0 1 13.75-28.3 36 36 0 1 0 0 56.61 35.94 35.94 0 0 1-13.75-28.31z" fill="#eb001b"/><path class="e" d="M120.5 65.76V64.6h.5v-.24h-1.19v.24h.47v1.16zm2.31 0v-1.4h-.36l-.42 1-.42-1h-.36v1.4h.26V64.7l.39.91h.27l.39-.91v1.06zM123.94 43.45a36 36 0 0 1-58.25 28.3 36 36 0 0 0 0-56.61 36 36 0 0 1 58.25 28.3z"/></svg>
 </div>
  <div>
  <span data-view="mastercard-selection" class="c-number"> * * 9 1 </span>
  <span data-view="visa-selection" class="c-number"> * * 4 6 </span>
  </div>
  <div>
    <svg class="arrow" width="16" height="14" viewBox="0 -3 14 16"xmlns="http://www.w3.org/2000/svg"><path stroke="#333" stroke-width="3" d="M1 14L8.412 3 15 14" fill="none" /></svg>
  </div>
</div>
<svg onclick="handleButtonClick()" role="button"  width="335" height="60" stroke-width="7" fill="var(--color-green)" stroke="var(--color-green)"><g><rect width="335" height="60" rx="25"/><text font-family="ArialMT, Arial" font-size="28" stroke="none" fill="#FFF"><tspan class="pay-text" x="108.342" y="38.5">Pay $100</tspan></text></g></svg>
<!-- <svg width="335" height="110" stroke="none">
  <rect width="335" height="100" />
</svg> -->

              
            
!

CSS

              
                :root {
  --main-bg-color: #FF4747;
  --card-background: #fff;
  --color-green: #00C46D;
  --light-gray: #a6a6a6;
}
body, html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Arimo', sans-serif;
}

body {
  background-color: var(--main-bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.card, .options {
  background: var(--card-background);
  padding: 18px;
  border-radius: 18px;
  box-shadow: 0 5px 15px hsla(0, 0%, 0%, .5);
  display: flex;
  align-items: center;
  width: 300px;
}

.card {
  height: 35px;
  margin: 20px;
  display: grid;
  grid-template-columns: 40px 70px 1fr 20px;
  cursor: pointer;
  
  & .c-number {
    font-family: Courier;
    color: var(--light-gray);
    font-size: 18px;
  }
}
.option {
  display: grid;
  grid-template-columns: 30px 70px 1fr;
  width: 100%;
  padding: 10px;
  align-items: center;
  
  & .c-number {
    font-family: Courier;
    color: var(--light-gray);
    font-size: 18px;
  }
}

.options {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 0px;
  overflow: hidden;
  padding: 0px;
}

.button {
  width: 335px;
  padding: 18px;
  border-radius: 18px;
  font-size: 20px;
  color: #fff;
  border: none;
  cursor: pointer;
  outline: none;
  font-weight: bold;
  
  &.-confirm {
    background: var(--color-green);
  }
}
.card {
  [data-view] { 
    display: none;
  }

  [data-active] { 
    display: inline-block;
  }  
}
.option {
  cursor: pointer;  
}

.tick {
  fill: var(--color-green)
}

.options {
  [data-view] { 
    display: none;
  }
  [data-active] {
    display: block;
  }
}

rect {
  fill: var(--color-green);
  stroke: var(--color-green);
}

svg[role="button"] {
  cursor: pointer;
}

              
            
!

JS

              
                console.clear()
let state = 'visa-selection'
let isPaying = false
 
const elViews = document.querySelectorAll('[data-view]');
const options = document.querySelector('.options')
const cardDetails = document.querySelector('.card')
const button = document.querySelector('svg[role="button"]')
const text = document.querySelector('.pay-text')
const arrow = document.querySelector('.arrow')


function setView(view) {
  TweenMax.fromTo(cardDetails, 0.4, { x: -50 }, { x: 0})
  elViews.forEach(el => {
    if(el.dataset.view === view) {
      el.dataset.active = true
    } else {
      delete el.dataset.active
    }
  })
}

function handleButtonClick() {
  if(!isPaying) {
     // check if options are open
  setOptionsDisplay(true)
  isPaying = true
  TweenMax.to(cardDetails, 0.4, { opacity: 0 })
  
  const tl = new TimelineMax() 
  tl.to("rect", 0.7, { fill: "#fff", onComplete: () => {text.innerHTML = "Paying...."} }).to("tspan", 0.7, { fill: "#333"}).to(button, 2, { y: -75 }).fromTo("rect", 7, {drawSVG:"0%"}, {drawSVG:"100%"}, 0.1).to(["rect", "tspan"], 0.7, {fill : "#00C46D", onComplete: () => {text.innerHTML = "Paid $100"} }).fromTo("tspan", 2, {x: -75, fill: "#fff", fillOpacity: 1}, {x : 20, fillOpacity: 1})
  } 
 
  
}

function setOptionsDisplay(reset = false){
  if(reset || options.style.height==="100px") {
    TweenMax.to(options, 0.4, { height: 0, padding: 0 })
   TweenMax.to(arrow, 0.4, { rotation: 360, transformOrigin:"50% 50%" })
  } else {
    TweenMax.fromTo(options, 0.4, { padding: 15 }, { height: 100 })
    TweenMax.to(arrow, 0.4, { rotation: 180, transformOrigin:"50% 50%" })
  }
}

setView('mastercard-selection')

// TweenMax.to("button", 5, {x : 50})
              
            
!
999px

Console