小粉兔简易计算器——一只小巨子

用HTML+CSS+JS实现一个简易的计算器:

<html>
<head>
<title>小粉兔计算器</title>

  <style>
   form.formtotal{
     background-image:url("file:///C:/Users/86136/Desktop/cute.jpg");
     height:400px;
	 width:400px;
   }
   div.divone{
     float:left;
     height:97%;
	 width:60%;
	 margin:6px;
   }
   input[type="text"]{
      font-size:x-large;
      float:left;
      width:235px; 
      height:50px;
	  border-radius: 13px;
	  background-color:#FFF7FB;
	  outline:none;
   }
   input[type="button"].btnone{
     font-size:large;
	 font-family:"华文行楷";
     width:29%;
	 height:20%;
	 border-radius: 13px;
	 background-color:#FFECF5;
	 margin-top:7px;
	 margin-left:4px;
	 cursor:pointer;
	 outline:none;
   }
   div.divtwo{
     float:right;
     width:34%;
     height:97%;
     margin:6px;
   }
   input[type="button"].backspace{
     font-family:"华文行楷";
	 font-size:x-large;
	 float:left;
	 width:48%;
	 height:50px;
	 border-radius: 13px;
	 background-color:#FFECF5;
	 cursor:pointer;
	 outline:none;
	}
	input[type="button"].delete{
	 font-family:"华文行楷";
	 font-size:x-large;
	 float:right;
	 width:48%;
	 height:50px;
	 border-radius: 13px;
	 background-color:#FFECF5;
	 cursor:pointer;
	 outline:none;
	}
	input[type="button"].btntwo{
	 font-family:"华文行楷";
	 font-size:x-large;
	 width:85%;
	 height:20%;
	 border-radius: 13px;
	 background-color:#FFECF5;
	 margin-top:7px;
     margin-left:10px;
	 cursor:pointer;
	 outline:none;
	}
	input[type="button"]:hover {
	 background-color: #FFECF5;
	 }
  </style>
</head>

<body>
  <form class="formtotal">
  <div class="divone">
    <input type="text" class="txt" id="textshow" /> 
    <input type="button" class="btnone" id="btn" value="1" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="2" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="3" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="4" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="5" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="6" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="7" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="8" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="9" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="0" onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone" id="btn" value="." onclick="caclufunction(this.value)"/>
	<input type="button" class="btnone id="btn" value="="  οnclick="caclufunction(this.value)"/>
  </div>

  <div class="divtwo">
	<input type="button" class="delete" id="btn" value="C" onclick="caclufunction(this.value)"/>
	<input type="button" class="backspace" id="btn" value="back" onclick="caclufunction(this.value)"/>
    <input type="button" class="btntwo" id="btn" value="+" onclick="caclufunction(this.value)"/>
	<input type="button" class="btntwo" id="btn" value="-" onclick="caclufunction(this.value)"/>
	<input type="button" class="btntwo" id="btn" value="*" onclick="caclufunction(this.value)"/>
	<input type="button" class="btntwo" id="btn" value="/" onclick="caclufunction(this.value)"/>
  </div>

  </form>
  <script>

	 function  caclufunction(val){
		var num = document.getElementById("textshow");
		
          switch (val) {

			case "back":
			   num.value=num.value.substring(0,num.value.length-1);
			   break;

            case "=":
                num.value = eval(num.value);
 
                break;
 
            case "C":
                num.value = "";
                break;
 
            default:
                num.value = num.value + val;
                break;
        }}

</script>
</body>
</html>
```![在这里插入图片描述](https://img-blog.csdnimg.cn/0a4acaaebc614eb9b910fca60d2d9df3.png#pic_center)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值