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

              
                <body>
	<div class="container-fluid">
		<div class="row ">

			<div class="coffee col-md-3 col-md-offset-2 col-sm-3 col-sm-offset-1 col-xs-9 col-xs-offset-1">
				<img class="steam" src="https://preview.ibb.co/easUWk/5.png">
				<img class="steam" src="https://preview.ibb.co/easUWk/5.png">
				<img class="steam2" src="https://image.ibb.co/iHCJP5/steam.png">
				<img class="steam2" src="https://image.ibb.co/iHCJP5/steam.png">
				<img class="mug" src="https://image.ibb.co/goH7HQ/mug.png">
			</div>
			<div class="cal-container col-md-6 col-md-offset-1 col-sm-6 col-sm-offset-1 col-xs-9 col-xs-offset-1 ">
				<section class="cal">
					<div class="cal-head">
						<h5 class="text-center">LEO'S JS CALCULATOR</h5>
					</div>
					<div class="cal-screen">
						<div class="mtext text-left"><span id="mtext">MEMORY</span></div>
						<div class="text text-right"><span id="text">0</span></div>
						<div class="ptext text-right"><span id="ptext"></span></div>
					</div>
					<div class="cal-buttons">
						<div class="top-buttons">
							<button class="btn top-btn" id="mcr">MRC</button>
							<button class="btn top-btn" id="subm">M-</button>
							<button class="btn top-btn" id="addm">M+</button>
							<button class="btn top-btn" id="sqrt">sqrt</button>
							<button class="btn top-btn" id="off">off</button>
						</div>
						<button class="btn cal-button" id="ac">AC</button>
						<button class="btn cal-button" id="ce">CE</button>
						<button class="btn cal-button " id="sign">+/-</button>
						<button class="btn cal-button " id="percent">%</button>

						<button class="btn cal-button number">7</button>
						<button class="btn cal-button number">8</button>
						<button class="btn cal-button number">9</button>
						<button class="btn cal-button operation">/</button>
						<button class="btn cal-button number">4</button>
						<button class="btn cal-button number">5</button>
						<button class="btn cal-button number">6</button>
						<button class="btn cal-button operation">*</button>
						<button class="btn cal-button number">1</button>
						<button class="btn cal-button number">2</button>
						<button class="btn cal-button number">3</button>
						<button class="btn cal-button operation">-</button>
						<button class="btn cal-button number">0</button>
						<button class="btn cal-button dot">.</button>
						<button class="btn cal-button" id="equal">=</button>
						<button class="btn cal-button operation">+</button>

					</div>
				</section>
			</div>

		</div>
	</div>
	<div class="dont-try-me">
		<img class="dtm center-block" src="https://media.tenor.com/images/3c1907df66bd8628754be3e815e40acc/tenor.gif">
	</div>
</body>
              
            
!

CSS

              
                body,
html {
	margin: 0;
	width: 100%;
	height: 100%;
}

body {
	background: url(http://i.imgur.com/82fcmZq.jpg) no-repeat fixed;
}

.coffee {
	position: relative;
	margin-top: 50px;
	width: 300px;
}

.coffee .mug {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	box-shadow: 6px 6px 4px #000;
}

.coffee .steam {
	z-index: 9;
	width: 100%;
	position: absolute;
	top: 20%;
	left: 5%;
	animation: move-steam 5s linear infinite;
}

.coffee .steam2 {
	z-index: 9;
	width: 60%;
	transform: rotate(90deg);
	-webkit-transform: rotate(90deg);
	-moz-transform: rotate(90deg);
	position: absolute;
	top: 10%;
	left: 25%;
	animation: move-steam2 3s ease-in-out infinite;
}

.cal-container {
	width: 300px;
	height: 500px;
	position: relative;
	margin-top: 50px;
	background-image: url(http://i.imgur.com/9Nb32rb.png);
	background-size: cover;
	background-position: center;
	border-radius: 30px;
	box-shadow: 6px 6px 4px #333, inset -1px -5px 2px 0.1px #888;
}

.cal-head {
	color: #c1c1c6;
	font-size: 20px;
	font-family: 'LCD14';
	font-weight: normal;
	font-style: normal;
}

.cal-screen {
	width: 80%;
	height: 80px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 75px;
	background-color: #d6e1e2;
	border: 1px solid #999;
	border-radius: 5px;
}

.cal-screen .text {
	font-size: 50px;
	margin-top: -25px;
	font-size-adjust: auto;
	font-family: 'LaylaDigitalRegular';
	font-weight: normal;
	font-style: normal;
	font-stretch: semi-condensed;
}

.cal-screen .mtext {
	font-size: 20px;
	margin-left: 5px;
	margin-top: -5px;
	color: #d6e1e2;
	font-family: 'LaylaDigitalRegular';
	font-weight: normal;
	font-style: normal;
}

.cal-screen .ptext {
	margin-top: -15px;
	font-size: 16px;
	font-family: 'LaylaDigitalRegular';
	font-weight: normal;
	font-style: normal;
}

.cal-buttons {
	display: inline-block;
	width: 100%;
	height: auto;
	margin-top: 40px;
	opacity: 0;
}

.cal-buttons .cal-button {
	width: 50px;
	height: 30px;
	margin: 0 5px 14px 9px;
}

.cal-buttons .top-buttons {
	margin-bottom: 15px;
}

.cal-buttons .top-buttons .top-btn {
	margin: 0 5px 0 5px;
	width: 40px;
	height: 25px;
}

.dont-try-me {
	z-index: 99;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	position: absolute;
	background: rgba(20, 25, 20, .8);
	display: none;
}

.dtm {
	margin-top: 100px;
	border-radius: 20px;
}

.off {
	animation: off 3s ease 1;
}

@keyframes off {
	0% {
		opacity: 0;
	}
	10% {
		opacity: 1;
	}
	91% {
		opacity: 1;
	}
	100% {
		opacity: 0;
	}
}

@keyframes move-steam {
	0% {
		transform: translateX(5%);
		opacity: 0;
	}
	10% {
		transform: translateX(5%);
		opacity: 1;
	}
	100% {
		transform: translateX(200px);
		opacity: 0;
	}
}

@keyframes move-steam2 {
	0% {
		transform: translateX(5%) rotate(90deg);
		opacity: 0;
	}
	20% {
		transform: translateX(15%) rotate(85deg);
		opacity: 1;
	}
	100% {
		transform: translateX(200px) rotate(60deg) translateY(15%);
		opacity: 0;
	}
}

              
            
!

JS

              
                $(document).ready(function () {
	var digit = /(\d|\))/;
	var input = '';
	var memory = 0;
	var isOpAllowed = true;
	var isDotAllowed = true;
	var $text = $('.cal-screen #text');
	var result = 0;
	var sqrtRequest = false;

	function showMath() {
		$('.cal-screen #ptext').text(input.replace(/\*/g, 'X').replace(/\//, '÷').replace('Math.sqrt(', '√').replace(')', ''));
	}

	function dot() {
		if (input == '') {
			input = '0' + $(this).text();
			$text.text('0' + $(this).text());
		} else {
			input += $(this).text();
			$text.text($text.text() + $(this).text());
		}
		showMath();
		isDotAllowed = false;
		$('.cal-buttons').find('.dot').unbind("click", dot);
	}


	function operation() {
		if (sqrtRequest) {
			input += ")" + $(this).text();
			sqrtRequest = false;
		} else input += $(this).text();
		$text.text('0');
		isOpAllowed = true;
		isDotAllowed = true;
		showMath();

		$('.cal-buttons').find('.operation').unbind("click", operation);

	}
	$('.cal-buttons').delegate('.number', "click", function () {
		if ($text.text()[$text.length - 1] == '.') $text.text('0');
		if ($(this).Text == '0' && (input == 'Digit Limit Reached.' || input == '0'))
			input = '';
		else {
			input += $(this).text();
			showMath();
		}
		if ($text.text().length == 10) {
			$text.text('0');
			$('.cal-screen #ptext').text('Digit Limit Reached.');
			input = '';
		} else {
			if ($text.text() != '0')
				$text.text($text.text() + $(this).text());
			else $text.text($(this).text());
		}
		if (isOpAllowed) {
			$('.cal-buttons').find('.operation').bind("click", operation);
		}
		if (isDotAllowed) {
			$('.cal-buttons').find('.dot').bind("click", dot);
		}
		isOpAllowed = false;
		isDotAllowed = false;
	});

	$('#ac').click(function () {
		input = '';
		$text.text('0');
		showMath();
		$text.removeAttr('data-toggle');
		$text.removeAttr('title');
		if (isDotAllowed)
			$('.cal-buttons').find('.dot').bind("click", dot);
	});
	$('#ce').click(function () {
		input = input.substr(0, input.length - 1);
		$text.text('0');
		showMath();
		if (isDotAllowed)
			$('.cal-buttons').find('.dot').bind("click", dot);
	});

	$('#equal').click(function () {
		if (sqrtRequest) {
			input += ")";
		}

		try {
			result = eval(input);
			if (result.toString().length > 10) {
				$text.text(result.toString().substr(0, 8) + '..');
				input = result.toString();
				showMath();
				$text.attr('data-toggle', 'tooltip');
				$text.attr('title', result.toString());

			} else {
				$text.text(result.toString());
				input = result.toString();
				showMath();

			}
		} catch (e) {
			$('.cal-screen #ptext').text('Syntax Err0r.');
			$text.text('0');
			input = '';

		}

	});

	$('#percent').click(function () {
		if (sqrtRequest) {
			input += ")/100";
			sqrtRequest = false;
		} else input += "/100";
		showMath();
	});
	$('#sign').click(function () {
		if (input[0] == '-') {
			input = input.substr(1, input.length);
			showMath();
		} else {
			input = "-" + input;
			showMath();
		}
	});
	$('#sqrt').click(function () {
		input += "Math.sqrt(";
		showMath();
		sqrtRequest = true;
	});
	$('#addm').click(function () {
		memory += eval($text.text());
		$('#mtext').css('color', '#000');
	});
	$('#subm').click(function () {
		if (memory != 0)
			memory -= eval($text.text());
	});
	$('#mcr').click(function () {
		if (memory.toString() < 11)
			$text.text(memory.toString());
		else {
			$text.text(memory.toString().substr(0, 8) + '..');
			$text.attr('data-toggle', 'tooltip');
			$text.attr('title', memory.toString());

		}
	});
	$('#mcr').dblclick(function () {
		memory = 0;
		$('#mtext').css('color', '#d6e1e2');
	});

	$('#off').click(function () {

		$('.dont-try-me').css('display', 'block');
		$('.dont-try-me').addClass('off');
		$('.dont-try-me').delay(3000).hide(function () {
			$('.dont-try-me').removeClass('off');
		});
	});
});

              
            
!
999px

Console