Pen Settings

HTML

CSS

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

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

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.

HTML

              
                div.section
  div.field.is-horizontal
    div.field-label.is-normal
      span.label 攻撃力
    div.field.field-body
      div.control
        input#atk.input.calc(type="number" placeholder="式神" min="0")
      span.label +
      div.control
        input#atk2.input.calc(type="number" placeholder="御魂" min="0")
      span.label =
      div.control
        input#atk-total.input(type="number" placeholder="合計攻撃力" min="0")
  div.field.is-horizontal
    div.field-label.is-normal
      span.label 会心DMG
    div.field-body.field.has-addons
      div.control
        input#dmg.input.calc(type="number" min="0")
      p.control
        span.button.is-static %
  div.field.is-horizontal
    div.field-label.is-normal
      span.label 餓者髑髏
    div.field-body
      div.select
        select#skul.input
          option(value="1") なし
          option(value="1.1") 10%
          option(value="1.25") 25%
  div.field.is-horizontal
    div.field-label.is-normal
      span.label =
    div.field-body
      div.control
        input#total.input(placeholder="total")
      div.control
        button#reset.button(style="margin-left:5rem") リセット
              
            
!

CSS

              
                .section {
    padding: 2rem 1.5rem 0;
}
.field.is-horizontal {
    display: flex;
}
.field-label.is-normal {
    padding-top: .375em;
}
.field-label {
    flex-basis: 0;
    flex-grow: 1;
    flex-shrink: 0;
    margin-right: 1.5rem;
    text-align: right;
}
.field-body {
    display: flex;
    flex-basis: 0;
    flex-grow: 5;
    flex-shrink: 1;
}
              
            
!

JS

              
                $(function() {
  const data = {
    atk: 0,
    atk2: 0,
    atks: 0,
    dmg: 0,
    skul: 1
  };

  const $total = $('#total');
  const $atkTotal = $('#atk-total');
  
  const totalCalc = () => {                     
    $total.val(Math.round(data.atks * (data.dmg / 100) * data.skul));
  }
  
  const calc = () => {
    const atks = Number($atkTotal.val())
    data.atks = data.atk + data.atk2 || atks ;
    $atkTotal.val(data.atks)      
    totalCalc()
  };
  
  const calc2 = () => {
    data.atks = Number($atkTotal.val());
    totalCalc()
  };
  
  $('.calc').on('change keyup mouseup', function() {
    const $this = $(this);
    const val = parseInt($this.val()) || 0;
    if (val === 0) return;
    data[$this.attr('id')] = val;
    calc();
  });
  $('#atk-total').on('change keyup mouseup', function() {
    const $this = $(this);
    const val = parseInt($this.val()) || 0;
    if (val === 0) return;
    data[$this.attr('id')] = val;
    calc2();
  })
  $('#skul').on('change', function() {
    data.skul = parseFloat($(this).val()) || 1;
    calc();
  });
  $('#reset').on('click', function() {
    $('input').val(null);
  })
});
              
            
!
999px

Console