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

              
                #app
  .calculator
    .header
      .logo Xiasio
      .title
        | Smart neumorphism
        br
        |calculator
    .display
      .display__inner
        .display__outer
          .display__value
            span(v-html="display") 0
    .separator
    .buttons
      .btn.btn_red(@click="clear")
        .btn__inner
          .btn__outer
            span C
      .btn.btn_orange(@click="sign")
        .btn__inner
          .btn__outer
            span +/-
      .btn.btn_orange(@click="percent")
        .btn__inner
          .btn__outer
            span %
      .btn.btn_orange(@click="divide")
        .btn__inner
          .btn__outer
            span ÷
      .btn(@click="append('7')")
        .btn__inner
          .btn__outer
            span 7
      .btn(@click="append('8')")
        .btn__inner
          .btn__outer
            span 8
      .btn(@click="append('9')")
        .btn__inner
          .btn__outer
            span 9
      .btn.btn_orange(@click="times")
        .btn__inner
          .btn__outer
            span X
      .btn(@click="append('4')")
        .btn__inner
          .btn__outer
            span 4
      .btn(@click="append('5')")
        .btn__inner
          .btn__outer
            span 5
      .btn(@click="append('6')")
        .btn__inner
          .btn__outer
            span 6
      .btn.btn_orange(@click="minus")
        .btn__inner
          .btn__outer
            span -
      .btn(@click="append('1')")
        .btn__inner
          .btn__outer
            span 1
      .btn(@click="append('2')")
        .btn__inner
          .btn__outer
            span 2
      .btn(@click="append('3')")
        .btn__inner
          .btn__outer
            span 3
      .btn.btn_orange(@click="add")
        .btn__inner
          .btn__outer
            span +
      .btn.btn_large(@mouseup="append('0')")
        .btn__inner
          .btn__outer
            span 0
      .btn(@click="dot")
        .btn__inner
          .btn__outer
            span .
      .btn.btn_orange(@click="equal")
        .btn__inner
          .btn__outer
            span
              | =
              
            
!

CSS

              
                html, body {
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
          align-items: center;
  -webkit-box-pack: center;
          justify-content: center;
  height: 100%;
  font-size: 2vh;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-tap-highlight-color: transparent;

  @media (max-width: 60vh) {
      font-size: 3.4vw; 
  }
}

.calculator {
  position: relative;

  width: 28rem;
  height: 46rem;

  margin: auto;
  padding: 1.875rem;

  border: 0.625rem solid #E8EEF3;
  box-sizing: border-box;
  border-radius: 1.875rem;

  background: linear-gradient(150.1deg, #F4F8FB 0%, #F8F8F8 100%);
  box-shadow: 0.625rem 0.625rem 1.25rem rgba(200, 212, 224, 0.5), -0.625rem -0.625rem 1.25rem #FFFFFF;

  -moz-user-select: none;

   -ms-user-select: none;

       user-select: none;
  -webkit-user-select: none;
}

.header {
  display: -webkit-box;
  display: flex;
  -webkit-box-pack: justify;
          justify-content: space-between;
  margin-bottom: 1.875rem;
}

.logo {
  font-family: TT Norms, sans-serif;
  font-style: normal;
  font-weight: bold;
  font-size: 1.5rem;
  line-height: 1.75rem;
  color: #31456A;
}

.title {
  font-family: TT Norms, sans-serif;
  font-style: normal;
  font-weight: 500;
  font-size: 0.625rem;
  line-height: 0.75rem;
  text-align: right;
  color: #31456A;
}

.display {
  padding: 0.5rem;
  color: rgba(68, 70, 66, 0.8);
  background: linear-gradient(284.34deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%), #E3ECF6;
  box-shadow: -0.625rem -0.625rem 1.25rem #FFFFFF, 0.625rem 0.625rem 1.875rem rgba(200, 212, 224, 0.5);
  border-radius: 1.875rem;

  &__inner {
    padding: 0.0625rem;
    background: linear-gradient(103.33deg, #FFFFFF 0%, #FEFFFF 0.01%, #99A2A4 100%);
    border-radius: 1.375rem;
  }

  &__outer {
    padding: 1.0625rem 1.875rem 0.4375rem;
    background: linear-gradient(108.47deg, #CCD4C6 -0.62%, #C9D3C1 25.06%, #C0CDB5 51.78%, #B3C1A7 78.51%, #AFBDA2 100%);
    border: 0.0625rem solid #727571;
    box-shadow: inset 0rem 0.25rem 0.625rem rgba(0, 0, 0, 0.25);
    border-radius: 1.25rem;
  }

  &__value {
    position: relative;
    font-family: Electronica-Normal, monospace;
    font-style: normal;
    font-weight: normal;
    font-size: 2.5rem;
    text-align: right;
    overflow: hidden;
    letter-spacing: 0.03rem;

    .dot {
      font-size: 0.8em;
      position: relative;
      display: inline-block;
      width: 0;
      overflow: visible;
      left: -0.2rem;
    }

    &:before {
      content: '8888888888888';
      position: absolute;
      top: 0;
      right: 0;
      opacity: 0.15;
    }
  }
}

.separator {
  height: 0.625rem;
  margin: 1.875rem -1.875rem;
  background: #F1F6FB;
  box-shadow: inset 0.3125rem 0.3125rem 0.625rem rgba(200, 212, 224, 0.5), inset -0.3125rem -0.3125rem 0.625rem #FFFFFF;
}

.buttons {
  margin: 0 -0.3125rem;
  -moz-user-select: none;
   -ms-user-select: none;
       user-select: none;
  -webkit-user-select: none;
}

.btn {
  $this: &;
  position: relative;
  display: inline-block;
  margin: 0.3125rem;
  padding: 0.3125rem;
  font-family: TT Norms;
  font-style: normal;
  font-weight: bold;
  font-size: 1.25rem;
  /* identical to box height */
  text-align: center;
  color: rgba(145, 155, 174, 0.8);
  background: #FFFFFF;
  box-shadow: 0.625rem 0.625rem 1.875rem rgba(200, 212, 224, 0.3), -0.625rem -0.625rem 1.25rem #FFFFFF, inset 0.3125rem 0.3125rem 1.25rem #DAE3EB;
  border-radius: 1.625rem;

  cursor: pointer;

  &__inner {
    padding: 0.125rem;
    background: linear-gradient(135deg, #F1F6FB 0%, rgba(255, 255, 255, 0.473958) 53.13%, #FFFFFF 75%, #F1F6FB 100%);
    box-shadow: 0.3125rem 0.3125rem 1.875rem rgba(200, 212, 224, 0.5), -0.625rem -0.625rem 1.25rem #FFFFFF;
    border-radius: 1.375rem;
  }

  &__outer {
    position: relative;

    width: 4.125rem;
    height: 4.125rem;
    overflow: hidden;
    background: linear-gradient(135deg, #F1F6FB 0%, rgba(255, 255, 255, 0.473958) 53.12%, #FFFFFF 75%, #F1F6FB 100%);
    border-radius: 1.25rem;
    -webkit-transition: background, box-shadow;
    transition: background, box-shadow;

    #{$this}_large & {
      width: 10.2rem;
    }

    #{$this}_down & {
      background: #F1F6FB;
      box-shadow: inset 0.3125rem 0.3125rem 0.625rem rgba(200, 212, 224, 0.5), inset -0.3125rem -0.3125rem 0.625rem #FFFFFF;

      span {
        -webkit-transform: scale(0.92);
                transform: scale(0.92);
      }
    }
  }

  span {
    position: relative;
    display: inline-block;
    padding: 1.375rem 0;
    -webkit-transition: -webkit-transform;
    transition: -webkit-transform;
    transition: transform;
    transition: transform, -webkit-transform;
  }

  &_red {
    color: #FFF;

    #{$this} {
      &__inner {
        background: #F73A3A;
        box-shadow: -0.625rem -0.625rem 1.25rem rgba(255, 255, 255, 0.5);
      }
      &__outer {
        background: linear-gradient(135deg, #E81A1A 0%, #FF6868 53.13%, #FD7373 75%, #E81A1A 100%);
      }
    }

    &#{$this}_down #{$this}__outer  {
      background: #FA3E3E;
      box-shadow: inset 0.3125rem 0.3125rem 0.625rem #DB0000, inset -0.3125rem -0.3125rem 0.625rem rgba(255, 255, 255, 0.2);
    }
  }

  &_orange {
    color: #FFF;

    #{$this} {
      &__inner {
        background: #F3831D;
        box-shadow: -0.625rem -0.625rem 1.25rem rgba(255, 255, 255, 0.5);
      }
      &__outer {
        background: linear-gradient(135deg, #E67208 0%, #F89B45 53.12%, #F89C47 75%, #F08828 100%);
      }
    }

    &#{$this}_down #{$this}__outer  {
      background: #F78924;
      box-shadow: inset 0.3125rem 0.3125rem 0.625rem #E36E03, inset -0.3125rem -0.3125rem 0.625rem rgba(255, 255, 255, 0.2);
    }
  }

  &_large {
    text-align: right;

    span {
      padding-right: 1.625rem;
    }
  }
}

              
            
!

JS

              
                new Vue ({
  el: '#app',
  data: () => ({
    current: "0",
    previous: null,
    operator: null,
    operatorClicked: false
  }),
  computed: {
    display() {
      let current = this.current;
      let max = 13;
      if (this.current.indexOf(".") !== -1) max++;
      current = current
        .replace(/^0+(\d)/, '$1')
        .replace(/^\./, '0.')
        .slice(0, max)
        .replace('.', '<span class="dot">,</span>');
      return current || 0;
    }
  },
  mounted() {
    document.querySelectorAll('.btn').forEach(el => {
      const down = e => el.classList.add('btn_down');
      const up = e => el.classList.remove('btn_down');
      el.addEventListener('mousedown', down, false);
      el.addEventListener('touchstart', down, false);
      el.addEventListener('mouseup', up, false);
      el.addEventListener('touchend', up, false);
    });
  },
  methods: {
    clear() {
      this.current = "0";
      this.previous = null;
      this.operator = null;
      this.operatorClicked = false;
    },
    sign() {
      if(this.current && this.current !== 0) {
        this.current = this.current.charAt(0) === "-"
            ? this.current.slice(1)
            : `-${this.current}`;
      }
    },
    percent() {
      if (this.current) this.current = `${parseFloat(this.current) / 100}`;
    },
    append(number) {
      if (this.operatorClicked) {
        this.current = "";
        this.operatorClicked = false;
      }
      this.current = `${this.current}${number}`;
    },
    dot() {
      if (this.current.indexOf(".") === -1) {
        this.append(".");
      }
    },
    setPrevious() {
      this.previous = this.current;
      this.operatorClicked = true;
    },
    divide() {
      this.equal();
      this.operator = (a, b) => b / a;
      this.setPrevious();
    },
    times() {
      this.equal();
      this.operator = (a, b) => a * b;
      this.setPrevious();
    },
    minus() {
      this.equal();
      this.operator = (a, b) => b - a;
      this.setPrevious();
    },
    add() {
      this.equal();
      this.operator = (a, b) => a + b;
      this.setPrevious();
    },
    equal() {
      if (this.previous && this.current && this.operator) {
        this.current = `${this.operator(
          parseFloat(this.current),
          parseFloat(this.previous)
        )}`;
        this.previous = null;
      }
    }
  }
});
              
            
!
999px

Console