HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,400,700" rel="stylesheet">
<div ng-app="calculatorApp">
<div class="main-container" >
<div class="bg-image"></div>
<div class="calculator-container" ng-controller="calculatorCtrl">
<div class="display-container">
<h1 ng-class="{ 'hide-result' : hideResult, 'medium-size' : result>9999999, 'small-size' : result>999999999, 'smallest-size': result>9999999999999, 'infinity-size': result==1/0 }" >{{ result | number }}</h1>
<h2 ng-class="{error : errorCounter>1, centered : firstTime, 'tracking-in-expand': firstTime}">{{ expression }}</h2>
</div>
<div class="keys-container noselect">
<div class="back-rectangle scale-up-center3"></div>
<div class="number-leaves-container scale-up-center1">
<div class="leaf-corner leaf-1" ng-click="handleClick('1')"><h3>1</h3></div>
<div class="leaf leaf-2" ng-click="handleClick('2')"><h3>2</h3></div>
<div class="leaf-corner leaf-3" ng-click="handleClick('3')"><h3>3</h3></div>
<div class="leaf leaf-4" ng-click="handleClick('4')"><h3>4</h3></div>
<div class="leaf leaf-6" ng-click="handleClick('6')"><h3>6</h3></div>
<div class="leaf-corner leaf-7" ng-click="handleClick('7')"><h3>7</h3></div>
<div class="leaf leaf-8" ng-click="handleClick('8')"><h3>8</h3></div>
<div class="leaf-corner leaf-9" ng-click="handleClick('9')"><h3>9</h3></div>
<div class="leaf leaf-5" ng-click="handleClick('5')"><h3>5</h3></div>
<div class="operations-leaves-container1 scale-up-center2">
<div class="leaf-corner leaf-1" ng-click="handleClick('-')"><h3 class="minus">–</h3></div>
<div class="leaf-corner leaf-3" ng-click="handleClick('.')"><h3 class="period">.</h3></div>
<div class="leaf-corner leaf-7" ng-click="clear(true)"><h3 class="ac">AC</h3></div>
<div class="leaf-corner leaf-9" ng-click="handleClick('*')"><h3 class="multiply">x</h3></div>
<div class="operations-leaves-container2">
<div class="leaf-corner leaf-1" ng-click="handleClick('0')"><h3 class="zero">0</h3></div>
<div class="leaf-corner leaf-3" ng-click="handleClick('+')"><h3 class="plus">+</h3></div>
<div class="leaf-corner leaf-7" ng-click="handleClick('/')"><h3 class="divide">÷</h3></div>
<div class="leaf-corner leaf-9" ng-click="clear(false)"><h3 class="percent">C</h3></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="show-info-button" title="View Information" ng-init="showInfo=false" ng-hide="showInfo" ng-click="showInfo = !showInfo">Info</div>
<div class="info-container" ng-class="{'shown-item': showInfo}">
<div class="info-panel">
<img src="https://wansoul.github.io/LotusCalculator/favicons/android-chrome-192x192.png" class="icon" />
<h1>Lotus Calculator</h1>
<h2>Calculator inspired by Lotus Flower</h2>
<p>I made the concept of this calculator as part of the DailyUI Design Challenge. I liked it so much and decided to code and make it work as a web app.</p>
<p>Check the project on my <a href="https://github.com/wansoul/LotusCalculator" title="See the source code on Github" target="-blank">Github</a>.</p>
<hr/>
<div class="contact-info-container">
<img src="https://wansoul.github.io/LotusCalculator/assets/avatar.jpg" class="avatar" />
<h3>Wan Souza</h3>
<h4>UX/UI Designer</h4>
<div class="social-icons">
<a href="https://www.behance.net/wansouza" title="Behance" class="behance" target="_blank">Behance</a>
<a href="https://www.linkedin.com/in/wansouza" title="LinkedIn" class="linkedin" target="_blank">LinkedIn</a>
<a href="https://github.com/wansoul" title="Github" class="github" target="_blank">Github</a>
<a href="https://twitter.com/wansoul" title="Twitter" class="twitter" target="_blank">Twitter</a>
</div>
</div>
<div class="close-button" title="Close this panel" ng-click="showInfo = !showInfo" >Close</div>
</div>
</div>
</div>
* {
-webkit-backface-visibility: hidden;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
body {
background-color: #000;
font-family: 'lato';
margin: 0;
overflow: hidden;
}
h3 {
font-size: 28px;
font-weight: 700;
opacity: 0.8;
}
.noselect {
-webkit-touch-callout: none;
/* iOS Safari */
-webkit-user-select: none;
/* Safari */
-khtml-user-select: none;
/* Konqueror HTML */
-moz-user-select: none;
/* Firefox */
-ms-user-select: none;
/* Internet Explorer/Edge */
user-select: none;
/* Non-prefixed version, currently
supported by Chrome and Opera */
}
.info-container{
position: absolute; z-index: 12;
left: 0; top: 0;
width: 100%; height: 100%;
opacity: 0;
transform: translateY(600px);
transition: all 0.3s ease-in-out;
}
.shown-item{
opacity: 1;
transform: translateY(0px);
}
.info-panel{
position: relative;
width: 90%; height: 440px;
min-width: 280px;
max-width: 300px;
top: 15%;
margin: 0 auto;
background-color: rgb(236, 241, 230);
text-align: center;
border-radius: 10px;
}
.info-panel > .icon{
width: 110px; height: 110px;
padding: 4px;
background-color: #fff;
box-shadow: 0 0 8px rgba(0,0,0,.3);
border-radius: 10px;
margin-top: -55px;
}
.info-panel > h1{
font-weight: 400;
font-size: 32px;
margin-bottom: 4px;
margin-top: 12px;
}
.info-panel > h2{
font-weight: 400;
width: 90%;
font-size: 16px;
opacity: .6;
margin: 6px auto 16px auto;
}
.show-info-button,
.info-panel > .close-button{
position: absolute;
width: 32px; height: 32px;
right: 12px; top: 12px;
display: block;
cursor: pointer;
overflow: hidden;
text-indent: 300px;
opacity: 0.6;
z-index: 15;
}
.close-button{
background: url(https://wansoul.github.io/LotusCalculator/assets/close.svg);
background-size: cover;
}
.show-info-button{
background: url(https://wansoul.github.io/LotusCalculator/assets/info.svg);
background-size: cover;
}
.show-info-button:hover,
.info-panel > .close-button:hover{
opacity: .9;
transform: scale(1.2);
}
.info-panel > p{
width: 90%;
text-align: left;
margin-left: auto;
margin-right: auto;
font-weight: 300;
}
/*## CONTACT INFO ####*/
.contact-info-container{
width: 90%;
margin: 0 auto;
}
.contact-info-container > h3{
font-size: 24px;
text-align: left;
margin-top: 16px;
font-weight: 400;
margin-bottom: 0;
}
.contact-info-container > h4{
font-size: 16px;
font-weight: 300;
text-align: left;
margin-top: 4px;
margin-bottom: 4px;
}
.avatar{
float: left;
margin-right: 12px;
width: 72px;
height: 72px;
border-radius: 50%;
}
.social-icons{
text-align: left;
}
.social-icons > a{
width: 32px; height: 32px;
display: inline-block;
background: url(https://wansoul.github.io/LotusCalculator/assets/behance.svg) no-repeat center;
overflow: hidden;
text-indent: 100px;
margin-right: 4px;
}
.social-icons > a:hover{
transform: scale(1.2);
}
.social-icons > a.behance{
margin-left: -4px;
}
.social-icons > a.linkedin{
background-image: url(https://wansoul.github.io/LotusCalculator/assets/linkedin.svg)
}
.social-icons > a.github{
background-image: url(https://wansoul.github.io/LotusCalculator/assets/github.svg)
}
.social-icons > a.twitter{
background-image: url(https://wansoul.github.io/LotusCalculator/assets/twitter.svg)
}
/*## BG IMAGE ####*/
.bg-image {
position: absolute;
width: 100vw;
height: 100vh;
background: url(https://wansoul.github.io/LotusCalculator/assets/bg.jpg);
background-size: cover;
z-index: 0;
}
.blur {
-webkit-filter: blur(10px);
-moz-filter: blur(10px);
-o-filter: blur(10px);
-ms-filter: blur(10px);
filter: blur(10px);
}
/*## MAIN VONTAINER ####*/
.main-container {
width: 100vw;
height: 100vh;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.8);
z-index: 1;
}
.calculator-container {
position: relative;
margin: 0 auto;
top: 20vh;
width: 254px;
height: 380px;
z-index: 1;
}
.display-container {
position: relative;
width: 90%;
height: 120px;
margin: 0 auto;
}
.display-container h1,
.display-container h2 {
right: 0;
min-width: 100%;
position: absolute;
color: #fff;
margin: 0 auto;
padding: 0;
}
.display-container h1 {
height: 69px;
font-weight: 100;
font-size: 58px;
line-height: 69px;
text-align: right;
margin-top: -8px;
transition: all 0.2s ease-in;
}
.display-container h2 {
top: 70px;
text-align: right;
font-weight: 300;
font-size: 21px;
opacity: 0.75;
}
.keys-container {
position: relative;
width: 100%;
height: 254px;
margin: 0 auto;
}
.back-rectangle {
position: absolute;
width: 177px;
height: 177px;
left: 40px;
top: 40px;
transform: rotate(45deg);
background-color: #7F0026;
opacity: 0.5;
}
.number-leaves-container {
position: absolute;
width: 204px;
height: 204px;
margin: 24px;
z-index: 3;
}
.leaf {
position: absolute;
width: 64px;
height: 64px;
cursor: pointer;
background-color: #D90845;
color: #fff;
box-shadow: 0 0 8px 0 rgba(72, 3, 23, 0.62);
z-index: 6;
font-size: 28px;
transition: transform 0.07s ease-in-out;
}
.leaf:hover {
background-color: #F50049;
transform: scaleX(1.1) scaleY(1.1) rotate(45deg);
}
.leaf h3 {
display: block;
margin: 20% 35%;
z-index: 10;
}
.leaf-corner {
position: absolute;
width: 70px;
height: 70px;
cursor: pointer;
background-color: #D90845;
color: #fff;
box-shadow: 0 0 8px 0 rgba(72, 3, 23, 0.62);
z-index: 5;
transition: transform 0.1s ease-in-out;
}
.leaf-corner:hover {
background-color: #F50049;
transform: scaleX(1.1) scaleY(1.1);
}
.leaf-corner h3 {
display: block;
cursor: pointer;
z-index: 10;
}
.leaf-5 {
left: 70px;
top: 70px;
border-radius: 50%;
transform: rotate(45deg);
}
.leaf-5 h3 {
transform: rotate(-45deg);
}
.leaf-6 {
left: 130px;
top: 70px;
border-radius: 50% 0 50% 50%;
transform: rotate(45deg);
}
.leaf-6 h3 {
transform: rotate(-45deg);
}
.leaf-4 {
left: 12px;
top: 70px;
border-radius: 50% 50% 50% 0;
transform: rotate(45deg);
}
.leaf-4 h3 {
transform: rotate(-45deg);
}
.leaf-2 {
left: 70px;
top: 128px;
border-radius: 50% 50% 0 50%;
transform: rotate(45deg);
}
.leaf-2 h3 {
transform: rotate(-45deg);
}
.leaf-8 {
left: 70px;
top: 12px;
border-radius: 0 50% 50% 50%;
transform: rotate(45deg);
}
.leaf-8 h3 {
transform: rotate(-45deg);
}
.leaf-9 {
left: 110px;
top: 24px;
border-radius: 50% 0 50% 50%;
}
.leaf-9 h3 {
margin: 3% 62%;
}
.leaf-1 {
left: 24px;
top: 110px;
border-radius: 50% 50% 50% 0;
}
.leaf-1 h3 {
margin: 43% 20%;
}
.leaf-3 {
left: 110px;
top: 110px;
border-radius: 50% 50% 0 50%;
}
.leaf-3 h3 {
margin: 46% 60%;
}
.leaf-7 {
left: 24px;
top: 24px;
border-radius: 0 50% 50% 50%;
}
.leaf-7 h3 {
margin: 3% 20%;
}
.operations-leaves-container1 {
position: absolute;
width: 100%;
height: 100%;
transform: rotate(23deg) scaleX(1.2) scaleY(1.2);
z-index: 2;
}
.operations-leaves-container1 .leaf-corner {
background-color: #A60031;
}
.operations-leaves-container1 .leaf-corner:hover {
background-color: #DC0041;
}
.operations-leaves-container1 h3 {
font-size: 21px;
font-weight: 400;
transform: rotate(-23deg);
}
.operations-leaves-container1 h3.minus {
margin: 45% 12%;
}
.operations-leaves-container1 h3.period {
font-size: 30px;
margin: 44% 68%;
}
.operations-leaves-container1 h3.ac {
font-size: 18px;
margin: -1% 6%;
}
.operations-leaves-container1 h3.multiply {
font-size: 19px;
margin: 7% 69%;
}
.operations-leaves-container2 {
position: absolute;
width: 100%;
height: 100%;
transform: rotate(-46deg);
z-index: 1;
}
.operations-leaves-container2 h3 {
font-size: 21px;
font-weight: 400;
transform: rotate(23deg);
}
.operations-leaves-container2 h3.zero {
margin: 68% 13%;
}
.operations-leaves-container2 h3.plus {
margin: 55% 66%;
}
.operations-leaves-container2 h3.divide {
margin: 16% 14%;
}
.operations-leaves-container2 h3.percent {
font-size: 18px;
margin: 6% 66%;
}
h2.error {
color: #F33535;
font-weight: 700;
-webkit-animation: shake-right 0.7s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
-moz-animation: shake-right 0.7s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
animation: shake-right 0.7s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
}
h2.centered {
text-align: center;
opacity: .9;
}
h1.hide-result {
transform: translateY(20px);
opacity: 0;
}
h1.medium-size {
font-size: 42px;
}
h1.small-size {
font-size: 32px;
}
h1.smallest-size {
font-size: 22px;
font-weight: 300;
}
h1.infinity-size {
font-size: 62px;
opacity: 0.8;
line-height: 48px;
}
/* ----------------------------------------------
* Generated by Animista on 2017-4-2 1:26:48
* http://animista.net
* T: @cssanimista
* ---------------------------------------------- */
.tracking-in-expand {
-webkit-animation: tracking-in-expand 0.7s cubic-bezier(0.215, 0.61, 0.355, 1) both;
-moz-animation: tracking-in-expand 0.7s cubic-bezier(0.215, 0.61, 0.355, 1) both;
animation: tracking-in-expand 0.7s cubic-bezier(0.215, 0.61, 0.355, 1) both;
}
.scale-up-center1 {
-webkit-animation: scale-up-center 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.5s both;
-moz-animation: scale-up-center 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.5s both;
animation: scale-up-center 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.5s both;
}
.scale-up-center2 {
-webkit-animation: scale-up-center2 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.6s both;
-moz-animation: scale-up-center2 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.6s both;
animation: scale-up-center2 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.6s both;
}
.scale-up-center3 {
-webkit-animation: scale-up-center3 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.7s both;
-moz-animation: scale-up-center3 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.7s both;
animation: scale-up-center3 0.7s cubic-bezier(0.39, 0.575, 0.565, 1) 0.7s both;
}
@-webkit-keyframes shake-right {
0%,
100% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transform-origin: 100% 50%;
transform-origin: 100% 50%;
}
10% {
-webkit-transform: rotate(2deg);
transform: rotate(2deg);
}
20%,
40%,
60% {
-webkit-transform: rotate(-4deg);
transform: rotate(-4deg);
}
30%,
50%,
70% {
-webkit-transform: rotate(4deg);
transform: rotate(4deg);
}
80% {
-webkit-transform: rotate(-2deg);
transform: rotate(-2deg);
}
90% {
-webkit-transform: rotate(2deg);
transform: rotate(2deg);
}
}
@keyframes shake-right {
0%,
100% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transform-origin: 100% 50%;
transform-origin: 100% 50%;
}
10% {
-webkit-transform: rotate(2deg);
transform: rotate(2deg);
}
20%,
40%,
60% {
-webkit-transform: rotate(-4deg);
transform: rotate(-4deg);
}
30%,
50%,
70% {
-webkit-transform: rotate(4deg);
transform: rotate(4deg);
}
80% {
-webkit-transform: rotate(-2deg);
transform: rotate(-2deg);
}
90% {
-webkit-transform: rotate(2deg);
transform: rotate(2deg);
}
}
@-webkit-keyframes tracking-in-expand {
0% {
letter-spacing: -0.5em;
opacity: 0;
}
40% {
opacity: 0.6;
}
100% {
opacity: 0.8;
}
}
@keyframes tracking-in-expand {
0% {
letter-spacing: -0.5em;
opacity: 0;
}
40% {
opacity: 0.6;
}
100% {
opacity: 0.8;
}
}
@keyframes scale-up-center {
0% {
-webkit-transform: scale(0.2) rotate(90deg);
transform: scale(0.2) rotate(90deg);
opacity: 0;
}
100% {
-webkit-transform: scale(1) rotate(0deg);
transform: scale(1) rotate(0deg);
opacity: 1;
}
}
@keyframes scale-up-center2 {
0% {
-webkit-transform: scale(0.2) rotate(90deg);
transform: scale(0.2) rotate(90deg);
opacity: 0;
}
100% {
-webkit-transform: scale(1.2) rotate(23deg);
transform: scale(1.2) rotate(23deg);
opacity: 1;
}
}
@keyframes scale-up-center3 {
0% {
-webkit-transform: scale(0.2) rotate(135deg);
transform: scale(0.2) rotate(135deg);
opacity: 0;
}
100% {
-webkit-transform: scale(1) rotate(45deg);
transform: scale(1) rotate(45deg);
opacity: 1;
}
}
'use strict'
var app = angular.module("calculatorApp", []);
app.controller("calculatorCtrl", function($scope){
$scope.result = "";
$scope.expression = "";
$scope.errorCounter = 0;
$scope.firstTime = true;
$scope.hideResult = true;
$scope.resultSize = "large";
resetDisplay();
$scope.clear = function(clearAll){
if(clearAll == false){
var size = $scope.expression.length;
if(size > 1 && $scope.firstTime == false){
$scope.expression = $scope.expression.substr(0, size-1);
evaluateExpression();
return;
}
}
resetDisplay();
}
$scope.handleClick = function(i){
if($scope.firstTime){
$scope.firstTime = false;
$scope.expression = i;
return;
}
$scope.expression += i;
evaluateExpression();
}
function evaluateExpression(){
try {
$scope.result = eval($scope.expression);
$scope.hideResult = false;
$scope.errorCounter = 0;
} catch (e) {
$scope.hideResult = true;
$scope.errorCounter++;
}
}
function resetDisplay(){
$scope.firstTime = true;
$scope.result = "";
$scope.expression = "LotusCalculator";
$scope.errorCounter = 0;
$scope.hideResult = true;
}
});
Also see: Tab Triggers