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

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

              
                <form id="nyuryoku">
  <div>
    <label>元の貯金</label>
    <input type="number" id="chokin" value="100">万円<br>
  </div>
  <div>
    <label>食費</label>
    <input type="number" id="syokuhi" value="3">万円/月<br>
  </div>
  <div>
    <label>水道光熱費</label>
    <input type="number" id="konetu" value="1">万円/月<br>
  </div>
  <div>
    <label>通信料</label>
    <input type="number" id="tusin" value="0.5">万円/月<br>
  </div>
  <div>
    <label>家賃</label>
    <input type="number" id="yatin" value="3">万円/月<br>
  </div>
  <div>
     <label>保険料</label>
     <input type="number" id="hoken" value="1.5">万円/月<br>
  </div>
  <div>
    <label>趣味・娯楽</label>
    <input type="number" id="syumi" value="1">万円/月<br>
  </div>
  <div>
    <label>その他諸費用</label>
     <input type="number" id="other" value="0">万円/月<br>
  </div>
  <div>
    <input type="button" id="button" value="計算する" onclick="keisan();">
  </div>
</form>
<hr>
<ul>
  <li>毎月の支出:<span id="sisyutu">○</span>万円</li>
  <li>貯金がゼロになるまで:あと<span id="nokori">○</span>ヵ月</li>
</ul>
              
            
!

CSS

              
                body{
	font-size:0.8rem;
}

form div{
  display: flex;
  margin-bottom:8px;
}

label{
  width:108px;
}

input{
  width:96px;
}

#button{
  font-weight:bold;
  padding:8px;
}

#sisyutu, #nokori{
  color:red;
  font-weight:bold;
}
              
            
!

JS

              
                function keisan()
{
  let sisyutu = 
      parseFloat(document.getElementById("syokuhi").value) +
      parseFloat(document.getElementById("konetu").value) +
      parseFloat(document.getElementById("tusin").value) +
      parseFloat(document.getElementById("yatin").value) +
      parseFloat(document.getElementById("hoken").value) +
      parseFloat(document.getElementById("syumi").value) +
      parseFloat(document.getElementById("other").value);
  let nokori =
      Math.round((parseFloat(document.getElementById("chokin").value) / sisyutu) * 10) / 10;
  document.getElementById("sisyutu").innerHTML = sisyutu;
  document.getElementById("nokori").innerHTML = nokori;
}
              
            
!
999px

Console