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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <div class="aside-sticky">
          <div class="aside-stripes visible">
            <div class="s1 aside-stripe"></div>
            <div class="s2 aside-stripe"></div>
          </div>

          <div class="card-scene-wrapper" style="opacity: 1;">
            <div class="card-scene" style="transform: rotateX(0.0827848rad) rotateY(-0.598887rad);">
              <div class="card-overlay" style="opacity: 0.95;">
                <div class="card-code" style="transform: translate3d(0px, -1380px, 0px);">
                  <div class="card-code">
<pre>  {
    id: <span class="code-string">'ic_hiahsdfUNihkasdf879'</span>,
    object: <span class="code-object">issuing_card</span>,
    authorization_controls: {
      allowed_categories: <span class="code-categories code-string" style="font-weight: 700;">['gas', 'parking']</span>,
      blocked_categories: <span class="code-null code-blocked">null</span>,
      currency: <span class="code-currency code-string" style="font-weight: 700;">'gbp'</span>,
      max_amount: <span class="code-number code-amount" style="font-weight: 700;">10000</span>,
      max_approvals: <span class="code-null">null</span>
    },
    billing: {
      address: {
        city: <span class="code-string">'beverly hills'</span>,
        country: <span class="code-string">'US'</span>,
        line1: <span class="code-string">'123 fake st'</span>,
        line2: <span class="code-null">null</span>,
        postal_code: <span class="code-number">90210</span>,
        state: <span class="code-string">'CA'</span>
      }
    },
    brand: <span class="code-string code-brand" style="font-weight: 700;">'mastercard'</span>,
    cardholder: <span class="code-null">null</span>,
    created: <span class="code-number">1528481070</span>,
    currency: <span class="code-string">'usd'</span>,
    exp_month: <span class="code-number">12</span>,
    exp_year: <span class="code-number">2022</span>,
    last4: <span class="code-number">1984</span>,
    livemode: <span class="code-number">false</span>,
    metadata: {
    },
    name: <span class="code-string">'Jenny Rosen'</span>,
    shipping: <span class="code-null">null</span>,
    status: <span class="code-string code-status" style="font-weight: 700;">'active'</span>,
    type: <span class="code-string code-type" style="font-weight: 700;">'virtual'</span>
  }
</pre>
</div>

                </div>
              </div>
            </div>

          <canvas width="1200" height="1200" style="width: 600px; height: 600px;"></canvas></div>
        </div>
              
            
!

CSS

              
                .aside-sticky, .card-scene { position: relative }
              
            
!

JS

              
                // declare the words
const words = [{
  selector: ".code-categories",
  text: ["'airfare'", "['gas', 'parking']"],
  scrollY: 0
}, {
  selector: ".code-type",
  text: ["'physical'", "'virtual'"],
  scrollY: -1390
}, {
  selector: ".code-brand",
  text: ["'visa'", "'mastercard'"],
  scrollY: -840
}, {
  selector: ".code-status",
  text: ["'inactive'", "'active'"],
  scrollY: -1380
}, {
  selector: ".code-currency",
  text: ["'gbp'", "'usd'"],
  scrollY: -120
}, {
  selector: ".code-amount",
  text: ["10000", "35"],
  scrollY: -190
}]

// alias $ to document.querySelector
const $ = document.querySelector.bind(document)

const element = $('.card-overlay')

const codeContainer = $(".card-code")

// set an initial currentStep and select the element from the DOM
const codeChanges = words.map(word => {
  return {
    ...word,
    currentStep: 0,
    el: $(word.selector)
  }
})

// method to scroll the codeContainer to the word
const scrollContainer = value => codeContainer.style.transform = `translate3d(0, ${value}px, 0)`

// type the text into the word element
const typeText = word => {
  const { el, newText } = word
  let num = 0
  // wait 500ms after its been scrolled to the text
  setTimeout(() => {
    if(el.classList.contains("code-null")) {
      el.classList.remove("code-null")
      el.classList.add("code-string")
    }
    // set a 50ms interval to simulate typing
    const timer = setInterval(() => {
      el.style.fontWeight = 700
      el.textContent = newText.substr(0, num)
      // if we're done with the word text, clear the interval
      num === newText.length && clearInterval(timer)
      num += 1
    }, 50)
  }, 500)
}

// type a word
const startTypingForStep = step => {
  const word = codeChanges[step]
  scrollContainer(word.scrollY)
  typeText({
    el: word.el,
    newText: word.text[word.currentStep]
  })
  // increment the currentStep, or reset it
  codeChanges[step] = {
    ...word,
    currentStep: word.currentStep === word.text.length - 1 ? 0 : word.currentStep + 1
  }
  const newStep = step === codeChanges.length - 1 ? 0 : step + 1
  // wait 4s before typing the next word
  setTimeout(() => startTypingForStep(newStep), 4e3)
}

// kick things off with the first word
startTypingForStep(0)
              
            
!
999px

Console