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 is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <div id="body-container" class="col-centered">
	<h1>Javascript Calculator</h1>
	<div id="calculator">	
		<div id="screen"></div>
		<button id="clear" type="button" class="btn btn-danger">C</button>
		<button id="divide" type="button" class="btn btn-info input">/</button>
		<button id="multiply" type="button" class="btn btn-info input">x</button>
		<button id="seven" type="button" class="btn btn-default input">7</button>
		<button id="eight" type="button" class="btn btn-default input">8</button>
		<button id="nine" type="button" class="btn btn-default input">9</button>
		<button id="subtract" type="button" class="btn btn-info input">–</button>
		<button id="four" type="button" class="btn btn-default input">4</button>
		<button id="five" type="button" class="btn btn-default input">5</button>
		<button id="six" type="button" class="btn btn-default input">6</button>
		<button id="add" type="button" class="btn btn-info input">+</button>
		<button id="one" type="button" class="btn btn-default input">1</button>
		<button id="two" type="button" class="btn btn-default input">2</button>
		<button id="three" type="button" class="btn btn-default input">3</button>
		<button id="equal" type="button" class="btn btn-success">=</button>
		<button id="zero" type="button" class="btn btn-default input">0</button>
		<button id="decimal" type="button" class="btn btn-default input">.</button>


                @import url(',700');

body {
	background-color: #37BC9B;
	font-family: "Lato", sans-serif;

h1 {
	text-align: center;
	color: #EEE;
	font-weight: 700;
	text-shadow: 1px 2px 2px rgba(0,0,0,0.3);

.col-centered {
    float: none;
    margin-left: auto;
	margin-right: auto;

#body-container {
	margin-top: 60px;
	width: 28em;
	max-height: 100vh;

#calculator {
	width: 100%;
	height: 58rem;
	background-color: #FFCE54;
	text-align: center;
	border-radius: 12px;
	box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
	font-weight: 900;
	padding: 2rem;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	grid-template-rows: 98px repeat(5, 1fr);
	grid-gap: 0.5em;
		"screen screen screen screen"
		"clear clear divide multiply"
		"seven eight nine subtract"
		"four five six add"
		"one two three equal"
		"zero zero decimal equal";
	$areas: screen, clear, divide, multiply, add, subtract, nine, eight, seven, six, five, four, three, two, one, zero, equal, decimal;
	@each $id in $areas {
		& > ##{$id} {
			grid-area: $id;
	#screen {
		background-color: #FFF;
		border-radius: 10px;
		border: 1px solid #DDD;
		padding: 5%;
		text-align: right;
		font-size: 6rem;
		color: #5BC0DE;
		box-shadow: inset 0px 0px 6px rgba(0,0,0,0.5);
		text-shadow: 0px 1px 1px rgba(0,0,0,0.3);
		text-justify: center;
		overflow-x: hidden;

	.btn {
		font-size: 3rem;
		font-weight: inherit;
		border-radius: 10px;
	#subtract, #add, #equal {
		font-size: 4rem;


    var $value = $(this).html().replace(/x/g, '*').replace(/–/g, '-');
    var $text = $("#screen").html();
    var $result = eval($("#screen").html());