Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


    h1.sw-title 640*480
    #res1.sw-res(data-w="640", data-h="480")
    h1.sw-title 1920*1080
    #res2.sw-res(data-w="1920", data-h="1080")
    h1.sw-title 720*480
    #res3.sw-res(data-w="720", data-h="480")
    h1.sw-title 任意のサイズ
          span.sw-option-context.x 横:
          input#ratio-w.sw-option-val(type="text", value="1920")
          span.sw-option-context.y 縦:
          input#ratio-h.sw-option-val(type="text", value="1080")
        button#res-btn.sw-res-btn(type="button") 計算


  padding: 20px
    margin-bottom 2em
    font-size 98%
      margin-bottom 20px
      margin-bottom 10px
        margin-bottom 0
      display inline-block
    cursor pointer
    margin-bottom 20px
      outline: none


 * 最大公約数を求める
function gcd(x, y){
  if(y === 0) return x
  return gcd(y, x % y)

 * 予め決めておいたアスペクト比の計算
const arr = ['res1','res2','res3']
for(let i = 0, iLen = arr.length; i < iLen; i++){
  const id = arr[i]
  const res = document.getElementById(id)
  const w = res.dataset.w
  const h = res.dataset.h
  const g = gcd(w,h)
  const ratio_w = w / g
  const ratio_h = h / g
  res.innerHTML = `結果:${ratio_w}:${ratio_h}`

const btn = document.getElementById('res-btn')
const ops_res = document.getElementById('res4')
const ops_w = document.getElementById('ratio-w')
const ops_h = document.getElementById('ratio-h')

 * 任意に入力したサイズのアスペクト比を計算
btn.addEventListener('click', ()=>{
  const w = ops_w.value - 0
  const h = ops_h.value - 0
  const g = gcd(w,h)
  const x = w / g
  const y = h / g
  ops_res.innerHTML = `結果:${x}:${y}`
}, false)