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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                document.body.style=`display: flex; font-size: 10px;`
const container = document.createElement('div')
container.style = `background-color: black; width: 50%; padding: 20px; border-radius: 15px;`
document.body.append(container)
/***************************************************************************
  DEMO
***************************************************************************/
const names = getnames(30)

for (var i = 0, N = names.length; i < N; i++) {
  const log2consle = makelog(names[i], consolelog)
  const log2dom = makelog(names[i], domlog)
  log2consle('foo', 'bar', 'baz')
  log2dom('foo', 'bar', 'baz')
}

/***************************************************************************/
function consolelog (...args) {
  console.log(...args)
}
/***************************************************************************/
function domlog (...args) {
  const [name, style] = args.splice(0, 2)
  const div = document.createElement('div')
  div.innerHTML = `
    <span style="${style}">${name.replace('%c', '')}</span>
    ${args.map(x => `<span style="color: white;">${x}</span>`).join(' ')}
  `
  div.style = 'margin: 10px;'
  container.appendChild(div)
}
/***************************************************************************
  NAMES
***************************************************************************/
function getnames (len = 90) {
  return `
    Maia
    Kaige
    Steele
    Zayah
    Empress
    Yahaira
    Phaedra
    Meadow
    Evalynne
    Lucius
    Yulissa
    Kannon
    Jefferson
    Alayna
    Linus
    Rihanna
    Anvita
    Celena
    Jenavieve
    Kylee
    Eliot
    Dalen
    Everhett
    Addeline
    Vivia
    Berkley
    Wilber
    Ameliah
    Adalie
    Kendalynn
    Fay
    Henri
    Davidson
    Nicco
    Morgan
    Jovanni
    Nona
    Marlin
    Sunni
    Nino
    Taelyn
    Jaylon
    Jc
    Naftuli
    Benedict
    Kaiser
    Parisa
    Tehya
    Nahom
    Nazar
    Pearson
    Ayva
    Gilbert
    Cort
    Fabrizio
    Darion
    Harrison
    Rivers
    Gloria
    Emmylou
    Aubrielle
    Dania
    Issac
    Deena
    Brigitte
    Ivaan
    Jebediah
    Lilyan
    Krue
    Seraphine
    Madilynne
    Donnie
    Irma
    Revan
    Myleah
    Cloud
    Aya
    Samara
    Jaythan
    Anand
    Mohammad
    Myanna
    Camdyn
    Sonja
    Jakson
    Ellaina
    Nevin
    Abdallah
    Kaycee
    Shmiel
  `.split('\n').map(x => x.trim()).filter (x => x).slice(0, len)
}
/***************************************************************************
  MAKELOG
***************************************************************************/
function makelog (name, logger) {
  return log
  function log (...args) {
    logger(...prepare(name, args))  
  }
  function prepare (name, args) {
    const arr = [`%c${name}`, getstyle(name)]
    args.map(x => arr.push(...(x === 'string' ? [`%c{x}`, getstyle(x)] : [x])))
    return arr
  }
  function getstyle (str) {
    var str1 = `x123${str}-${str}`
    var str2 = `${str}-color-${str}`
    function gethash (str, hash = 0) {
      for (var i = 0; i < str.length; i++) {
        hash = str.charCodeAt(i) + ((hash << 5) - hash)
        hash = hash & hash
      }
      return Math.floor(hash)        
    }
    function getcolor (hash) {
      var hue =  [0, 360]
      var sat = [90,100]
      var lit = [41, 72]
      var h = range(hash, ...hue) % 361
      var s = range(hash, ...sat) % 100
      var l = range(hash, ...lit) % 100
      return [h, s, l]
      function range (hash, min, max) {
        var diff = max - min
        return (((hash % diff) + diff) % diff) + min
      }
    }
    var [h1, s1, l1] = getcolor(gethash(str1))
    var [h2, s2, l2] = getcolor(gethash(str2))
    var style = ''
    const H = 50
    const L = 25
    if (Math.abs(h1 - h2) < H) adjust(1)
    if (h1 < h2 && Math.abs(h1 - (360 - h2)) < H) adjust(2)
    if (h1 > h2 && Math.abs(h2 - (360 - h1)) < H) adjust(3)
    adjust()
    var col1 = `hsl(${h1},${s1}%,${l1}%)`
    var col2 = `hsl(${h2},${s2}%,${l2}%)`
    style += `background-color: ${col1}; color: ${col2};`
    style += `border-radius: 3px; padding: 3px; font-family: monospace; font-weight: bold;`

    return style
    function adjust (mode) {
      if (mode === 1) h1 < h2 ?
        h1 < 180 ? (h2 += 60) : (h1 -= 60)
        : h2 < 180 ? (h1 += 60) : (h2 -= 60)
      if (mode === 2) (h1 += 30, h2 -= 30)
      if (mode === 3) (h2 += 30, h1 -= 30)
      if (Math.abs(l1 - l2) < L) l1 < l2 ? (l1 -= L, l2 += L) : (l2 -= L, l1 += L) 
    }
  }
}
              
            
!
999px

Console