用JS的点击事件和事件委托做一个简单的计算器(加减乘除,清除),下面就是计算器的样子,这里主要是用js,样式就随便设置,可能有点丑了;
首先大概写出计算器的样子,简单设置一下样式
<style>
.icon {
width: 500px;
height: 600px;
border: 1px solid #000000;
position: relative;
margin: 100px auto;
}
.show {
width: 350px;
height: 60px;
border: 1px solid #000000;
margin: 20px auto;
text-align: center;
line-height: 70px;
}
.bn {
float: left;
width: 80px;
height: 80px;
border-radius: 50%;
font-size: 20px;
text-align: center;
line-height: 80px;
font-weight: bold;
border: 1px solid #000000;
margin: 20px;
}
</style>
<div class="icon">
<div class="show"></div>
<div class="bn">7