效果图:

  

代码:

<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
/* Basic Reset */ * {
border: none;
font-family: 'Open Sans', sans-serif;
margin: ;
padding: ;
} body {} .center {
background-color: #fff;
border-radius: %;
height: 600px;
margin: auto;
width: 600px;
} h1 {
color: #;
font-size: 30px;
margin-top: 20px;
padding-top: 50px;
display: block;
text-align: center;
text-decoration: none;
} a {
color: #;
font-size: 30px;
display: block;
text-align: center;
text-decoration: none;
padding-top: 20px;
} form {
background-color: #;
box-shadow: 4px 4px #3d4a65;
margin: 40px auto;
padding: 40px 30px 40px;
width: 280px;
} .btn {
outline: none;
cursor: pointer;
font-size: 20px;
height: 45px;
margin: 5px 5px 10px;
width: 45px;
} .btn:first-child {
margin: 5px 5px 10px;
} .btn,
#display,
form {
border-radius: 25px;
} #display {
outline: none;
background-color: #98d1dc;
box-shadow: inset 6px 6px 0px #3facc0;
color: #;
font-size: 20px;
height: 47px;
text-align: right;
width: 165px;
padding-right: 10px;
margin-left: 10px;
} .number {
background-color: #72778b;
box-shadow: 5px #5f6680;
color: #dededc;
} .number:active {
box-shadow: 2px #5f6680;
-webkit-transform: translateY(2px);
-ms-transform: translateY(2px);
-moz-tranform: translateY(2px);
transform: translateY(2px);
} .operator {
background-color: #dededc;
box-shadow: 5px #bebebe;
color: #72778b;
} .operator:active {
box-shadow: 2px #bebebe;
-webkit-transform: translateY(2px);
-ms-transform: translateY(2px);
-moz-tranform: translateY(2px);
transform: translateY(2px);
} .other {
background-color: #e3844c;
box-shadow: 5px #e76a3d;
color: #dededc;
} .other:active {
box-shadow: 2px #e76a3d;
-webkit-transform: translateY(2px);
-ms-transform: translateY(2px);
-moz-tranform: translateY(2px);
transform: translateY(2px);
}
</style>
</head> <body>
<div class="center">
<h1>HTML CSS, JavaScript 计算器</h1>
<a href="https://github.com/guuibayer/simple-calculator" target="_blank"><i class="fa fa-github"></i></a>
<form name="calculator">
<input type="button" id="clear" class="btn other" value="C">
<input type="text" id="display">
<br>
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn operator" value="+" onclick="get(this.value);">
<br>
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn operator" value="*" onclick="get(this.value);">
<br>
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn operator" value="-" onclick="get(this.value);">
<br>
<input type="button" class="btn number" value="" onclick="get(this.value);">
<input type="button" class="btn operator" value="." onclick="get(this.value);">
<input type="button" class="btn operator" value="/" onclick="get(this.value);">
<input type="button" class="btn other" value="=" onclick="calculates();">
</form>
</div>
</body> </html>
<script type="text/javascript">
/* limpa o display */
document.getElementById("clear").addEventListener("click", function() {
document.getElementById("display").value = "";
});
/* recebe os valores */
function get(value) {
document.getElementById("display").value += value;
} /* calcula */
function calculates() {
var result = ;
result = document.getElementById("display").value;
document.getElementById("display").value = "";
document.getElementById("display").value = eval(result);
};
</script>

HTML CSS, JavaScript 计算器的更多相关文章

  1. html css javascript 加载的顺序

    html /css /javascript 这三者的加载顺序影响整个页面的加载速度.而加载速度的快慢直接影响pv(访问量),而且会影响经济收入.在大网站中,可能打开速度快一秒,一年能多带来上亿的收入. ...

  2. Sublime Text插件:HTML+CSS+JAVASCRIPT+JSON快速格式化[转]

    今天在github上乱逛,无意间找到victorporof分享的htmlpretty插件,特做推荐: 先看看他是怎么描述htmlpretty的: This is a Sublime Text 2 an ...

  3. html+css+javascript实现列表循环滚动示例代码

    使用html+css+javascript实现列表循环滚动,设置时间定时,在规定的时间内替换前一个节点的内容,具体示例如下,感兴趣的朋友可以参考下 说明:设置时间定时,在规定的时间内替换前一个节点的内 ...

  4. HTML+CSS+JAVASCRIPT 总结

    1. HTML 1: <!doctype html> 2: <!-- This is a test html for html, css, javascript --> 3: ...

  5. Umbraco(3) - CSS & Javascript(翻译文档)

    原文地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/umbraco3css-javascript/ CSS & Jav ...

  6. 原创的基于HTML/CSS/JavaScript的层级目录树

    之前参加过一些基于HTML/CSS/JavaScript的项目,当在页面中需要生成一颗目录树时,总是首先想着网上有没有现成的生成树的源代码,比如dtree.zthee,或者使用一些javascript ...

  7. MiniCodeEditor:只有168字节的在线Html/CSS/JavaScript编辑器

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:MiniCodeEditor:只有168字节的在线Html/CSS/JavaScript编辑器.

  8. CSS+Javascript的那些框架

    CSS CSS 制作框架 SASS http://www.oschina.net/p/sass Blueprint  http://www.oschina.net/p/blueprintcss Ela ...

  9. 3 Ways to Preload Images with CSS, JavaScript, or Ajax---reference

    Preloading images is a great way to improve the user experience. When images are preloaded in the br ...

随机推荐

  1. noip模拟赛 洗澡

    分析:首先肯定是要用线性筛把素数全部给筛出来的,然后可以维护一个前缀和数组记录1~i个素数的和,对于每一个询问可以从n到1+k枚举它的右端点,然后利用前缀和统计一个长度为K的区间和,看看是不是满足条件 ...

  2. hdu 3062 2-sat

    #include<stdio.h> #include<string.h> #define N 2100 struct node { int u,v,next; }bian[N* ...

  3. Javascript网址跳转方法

    第一种: window.location.href="http://www.baidu.com"; 第二种: window.navigate("http://www.ba ...

  4. Node: Updating npm's bundled node gyp

    Linux, Mac OS X, Solaris, etc. Unix is easy. Just run the following command. Use sudo if necessary. ...

  5. CentOS 7: 配置Network

    Command Mode Step 1 » Network interface config files are located in /etc/sysconfig/network-scripts/  ...

  6. MQTT---HiveMQ源代码具体解释(一)概览

    源博客地址:http://blog.csdn.net/pipinet123 MQTT交流群:221405150 面向群体 想自己实现MQTT Broker的朋友 对现有开源的MQTT Broker或多 ...

  7. [Vue @Component] Write Vue Functional Components Inline

    Vue's functional components are small and flexible enough to be declared inside of .vue file next to ...

  8. AutoCAD如何移动坐标原点

    通常在CAD画图设计时,坐标原点都默认在左下角,下面就来分享一下在CAD如何把左下角的坐标原点移动到我们画的图形中心点: 1.输入坐标原点移动命令UCS: 按回车确认后,再输入M(就是移动的意思): ...

  9. SuperSwipeRefreshLayout 一个功能强大的自己定义下拉刷新组件

    SuperSwipeRefreshLayout 一个功能强大的自己定义下拉刷新组件. Why? 下拉刷新这样的控件.想必大家用的太多了,比方使用非常多的XListView等. 近期.项目中非常多列表都 ...

  10. Python图像处理库:PIL中Image,ImageDraw等基本模块介绍

    Python图像处理库:PIL中Image,ImageDraw等基本模块介绍 标签: 图像处理PILPYTHON 2016-08-19 10:58 461人阅读 评论(0) 收藏 举报  分类: 其他 ...