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


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.


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.


    input#form.form.tar(type="number", value="0") 
    span.unit byte
    button#change.btn(type="button") 変換


  padding 20px
  margin-bottom 20px
    margin-bottom 0
  text-align right
  display inline-block
  margin-left 10px
  padding 10px

  cursor: pointer
    outline: none


 * ファイルサイズを適切な単位に変換
 * @param {number} size
 * @return {*}
const UnitChangeForByte = (size) => {
  const { target, unit } = getTarget(size)
const newSize = target !== null ? Math.floor((size / target) * Math.pow(10, 2)) / Math.pow(10, 2) : size

  return newSize + unit

 * 入力されたファイルサイズを元に計算につかうバイト数と単位を返却
 * @param {number} size
 * @return {{target, unit}}
function getTarget (size) {
  const kb = 1024
  const mb = Math.pow(kb, 2)
  const gb = Math.pow(kb, 3)
  const tb = Math.pow(kb, 4)

  const returnData = (target, unit) => ({ target, unit })

  if (size >= tb) return returnData(tb, 'TB')
  if (size >= gb) return returnData(gb, 'GB')
  if (size >= mb) return returnData(mb, 'MB')
  if (size >= kb) return returnData(kb, 'KB')

  return returnData(null, 'byte')

const input = $('#form')
const result = $('#result')

$('#change').on('click', ()=>{
  const val = parseInt(input.val(), 10)
  result.text(UnitChangeForByte(parseInt(input.val(), 10)))