cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div class="container" id="app">
  <div class="row">
    <div class="col s12 m5 push-m3">
      <h4 class="center white-text">Calculator</h4>
    </div>
  </div>
  <div class="row">
    <div class="col s12 m5 l5 card-panel outer-frame push-m3 push-l3">
      <div class="row results">
        <div class="col s12 m12 results--div">
          <div class="res">{{result}}</div>
          <div class="cal">{{numbers}}</div>
        </div>
      </div>
      <div class="row btn-group">
        <div class="col s3 m3 btn-line">
          <a href="#" v-on:click="calculate(1)" class="btn-flat waves-effect waves-black">1</a>
          <a href="#" v-on:click="calculate(5)" class="btn-flat waves-effect waves-black">5</a>
          <a href="#" v-on:click="calculate(8)" class="btn-flat waves-effect waves-black">8</a>
          <a href="#" v-on:click="calculate('.')" class="btn-flat waves-effect waves-black" id="bottom-left">.</a>
        </div>
        <div class="col s3 m3 btn-line">
          <a href="#" v-on:click="calculate(2)" class="btn-flat waves-effect waves-black">2</a>
          <a href="#" v-on:click="calculate(6)" class="btn-flat waves-effect waves-black">6</a>
          <a href="#" v-on:click="calculate(9)" class="btn-flat waves-effect waves-black">9</a>
          <a href="#" v-on:click="getResult" class="btn-flat waves-effect waves-black">=</a>
        </div>
        <div class="col s3 m3 btn-line">
          <a href="#" v-on:click="calculate(3)" class="btn-flat waves-effect waves-black">3</a>
          <a href="#" v-on:click="calculate(7)" class="btn-flat waves-effect waves-black">7</a>
          <a href="#" v-on:click="calculate(0)" class="btn-flat waves-effect waves-black">0</a>
          <a href="#" v-on:click="clear" class="btn-flat waves-effect waves-black">C</a>
        </div>
        <div class="col s3 m3 btn-line">
          <a href="#" v-on:click="calculate('+')" class="btn-flat waves-effect waves-black">+</a>
          <a href="#" v-on:click="calculate('-')" class="btn-flat waves-effect waves-black">-</a>
          <a href="#" v-on:click="calculate('/')" class="btn-flat waves-effect waves-black">/</a>
          <a href="#" v-on:click="calculate('*')" class="btn-flat waves-effect waves-black" id="bottom-right">*</a>
        </div>
      </div>
    </div>
  </div>
</div>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Droid+Sans');
body{
  font-family: 'Droid Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
  background-color: #004C38;
}
.container > .row{
  margin: auto;
}
.outer-frame{
  margin-top: 2%;
  box-shadow: 1px 1px 1px grey. 
            -1px -1px -1px grey;
  border-radius: 14px;
  background-color: #3B5249;
}
.res{
  font-size: 2em;
  padding-top: 1em;
  padding-left: 0.5em;
}
.cal{
  font-size:1.4em;
  text-align: right;
  padding: 1em 0em;
}
.results{
  margin-bottom: 0%;
  background-color: #001F16;
  color: #FFF;
  padding: 15px;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}
.results--div{
  background-color: #002E21;
}
.btn-group{
  margin-bottom: 0px;
}
.btn-line{
  padding: 0px !important;
  text-align: center;
}
a.btn-flat{
  font-size: 1.2em;
  font-weight: thin;
  color: #FFF;
  background-color: #70817A;
  width: 100% !important;
  border-radius: 0px;
  padding-top: 3em;
  line-height: 0.5;
  padding-bottom: 3em !important;
}
#bottom-left{
  border: 0px solid black;
  border-bottom-left-radius:14px;
}
#bottom-right{
  border-bottom-right-radius:14px;
}
            
          
!
            
              var app = new Vue({
  el: '#app',
  data:{
    result: 0,
    numbers: '0',
  },
  mounted(){
    $(function(){
      $("a").on("click", e=>{
        e.preventDefault();
      })
    });
  },
  methods:{
    calculate(n){
      this.numbers = (this.numbers == '0')? 
              ((typeof n == 'string')?
                  this.numbers : n)
                  : this.numbers + ""+ n;
    },
    getResult(){
      this.result = eval(this.numbers);
    },
    clear(){
      this.result = 0;
      this.numbers = 0;
    }
  }
})
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console