首页 > 其他分享 >简易计算机

简易计算机

时间:2023-07-07 15:15:03浏览次数:28  
标签:计算机 value height 简易 getElementById document margin screenName

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font: 14px Arial, sans-serif;
}

html {
height: 100%;
background-color: lightslategrey;
}

#calculator {
margin: 15px auto;
width: 330px;
height: 400px;
border: 1px solid lightgray;
background-color: darkgrey;
padding: 15px;
}

/*LOGO*/
.LOGO {
height: 30px;
}

.LOGO .name {
margin: 0 100px;
line-height: 30px;
}

/*screen*/
#shuRu {
margin-top: 15px;
}

.screen {
margin-top: 5px;
width: 300px;
height: 40px;
text-align: right;
padding-right: 10px;
font-size: 20px;
}

#keys {
border: 1px solid lightgray;
height: 223px;
margin-top: 25px;
padding: 8px;
}

#keys .last {
margin-right: 0px;
}

#keys .buttons {
float: left;
width: 42px;
height: 36px;
text-align: center;
background-color: lightgray;
margin: 0 17px 20px 0;
}
</style>
</head>

<body>
<div id="calculator">
<div class="LOGO">
<span class="name">简单的计算器</span>
</div>
<div id="shuRu">
<!--screen输入栏-->
<div class="screen">
<input type="text" id="screenName" name="screenName" class="screen">
</div>
</div>
<div id="keys">
<!--第一排-->
<input type="button" id="7" onclick="jsq(this.id)" value="7" class="buttons">
<input type="button" id="8" onclick="jsq(this.id)" value="8" class="buttons">
<input type="button" id="9" onclick="jsq(this.id)" value="9" class="buttons">
<input type="button" id="Back" onclick="tuiGe()" value="Back" class="buttons">
<input type="button" id="C" onclick="clearNum()" value="C" class="buttons" style="margin-right:0px">
<!--第二排-->
<input type="button" id="4" onclick="jsq(this.id)" value="4" class="buttons">
<input type="button" id="5" onclick="jsq(this.id)" value="5" class="buttons">
<input type="button" id="6" onclick="jsq(this.id)" value="6" class="buttons">
<input type="button" id="*" onclick="jsq(this.id)" value="*" class="buttons">
<input type="button" id="/" onclick="jsq(this.id)" value="/" class="buttons" style="margin-right:0px">
<!--第三排-->
<input type="button" id="1" onclick="jsq(this.id)" value="1" class="buttons">
<input type="button" id="2" onclick="jsq(this.id)" value="2" class="buttons">
<input type="button" id="3" onclick="jsq(this.id)" value="3" class="buttons">
<input type="button" id="+" onclick="jsq(this.id)" value="+" class="buttons">
<input type="button" id="-" onclick="jsq(this.id)" value="-" class="buttons" style="margin-right:0px">
<!--第四排-->
<input type="button" id="0" onclick="jsq(this.id)" value="0" class="buttons">
<input type="button" id="00" onclick="jsq(this.id)" value="00" class="buttons">
<input type="button" id="." onclick="jsq(this.id)" value="." class="buttons">
<input type="button" id="%" onclick="jsq(this.id)" value="%" class="buttons">
<input type="button" id="eva" onclick="eva()" value="=" class="buttons" style="margin-right:0px">
</div>
</div>
</body>
<script>
function jsq(num) {
console.log(num);
//获取当前输入
if (num == "%") {
document.getElementById('screenName').value = Math.round(document.getElementById('screenName').value) / 100;
} else {
document.getElementById('screenName').value += document.getElementById(num).value;
}
}
function eva() {
//计算输入结果
// var res=document.getElementById("screenName").value;
// console.log(res);
// document.getElementById("screenName").value=eval(res)
document.getElementById("screenName").value = eval(document.getElementById('screenName').value);
}
function clearNum() {
//清0
document.getElementById("screenName").value = null;
document.getElementById("screenName").focus();
}
function tuiGe() {
//退格
var arr = document.getElementById("screenName");
arr.value = arr.value.substring(0, arr.value.length - 1);
}
</script>

</html>

标签:计算机,value,height,简易,getElementById,document,margin,screenName
From: https://www.cnblogs.com/ckyjbd/p/17534996.html

相关文章

  • 如何实现计算机视觉 pdf的具体操作步骤
    实现计算机视觉PDF的步骤作为一名经验丰富的开发者,我很乐意教会你如何实现“计算机视觉PDF”。下面是整个过程的步骤表格:步骤操作代码示例第一步安装必要的库和工具pipinstallopencv-python<br>pipinstallPyPDF2第二步将PDF转换为图片importcv2<br>im......
  • 计算机与服务器之间的关系
    1.计算机1.1计算机的起源历史计算机的历史可以追溯到200多年前。最初由数学家和企业家提出的理论,在19世纪,机械计算机的设计和制造是为了解决日益复杂的数字运算挑战。到20世纪初,技术的进步使计算机变得越来越复杂,计算机变得更大、更强大。今天,计算机几乎无法从19世纪的......
  • 计算机组成原理-运算器实验(1)
    实验2运算器实验(1)学号:    姓名:一、 实验目的1.掌握开源数字电路模拟软件Logisim的使用;2.掌握有符号数加减运算溢出检测的基本方法;3.掌握运算器的组成及其工作原理;4.验证4位函数发生器74181的组合功能。 二、实验设备EL-JY-II型计算机组成原理实验系统一套,排线若......
  • 一套比较完整的字节面试题,包含计算机网络、操作系统、前端等
    一、算法和数据结构 实现一个函数,判断两个给定的字符串是否为异构字符串。异构字符串是指由相同字符但顺序不同的字符串。例如,“abb”和“bab”就是异构字符串。答案:functionisIsomorphic(str1,str2){if(str1.length!==str2.length){returnfalse;}......
  • 第三届计算机应用与信息安全国际会议(ICCAIS2023)
    由湖北省众科地质与环境技术服务中心主办的2023第三届计算机应用与信息安全国际会议(ICCAIS2023)将于2023年12月20-22日在中国武汉召开。 ICCAIS2023力图建立 一个国际化的计算机应用与信息安全领域的学术交流平台,分享最新进展和研究成果。期待您的参与。 ★重要信息大会时间:20......
  • 【后端面经-计算机基础】HTTP和TCP的区别
    【后端面经-计算机基础】HTTP和TCP的区别目录【后端面经-计算机基础】HTTP和TCP的区别1.OSI七层模型和相关协议2.TCP协议2.1特点:2.2报文格式2.3三次握手和四次挥手3.HTTP协议3.1特点3.2报文格式3.2https和http4.HTTPvsTCP5.面试模拟参考资料1.OSI七层模型和相关协......
  • 计算机网络考后有感
    一、前言这一科的知识点太多了,于我而言速成有点不太可能,吃不消,刚刚考完,不知道结果如何,在此记录一下二、考试类型题及相关题1、简答题1.举例什么情况下是高带宽、高延迟,什么情况下是低带宽、低延迟?2.对比一下光纤和铜线的优缺点3.叙述一下TCP三次握手的过程,并说明为什么是三......
  • 【AI新趋势期刊#2】AI发明计算机算法,如何给大模型排行,照片秒变二维码,视频一键动漫风
    前言每天都要浏览大量AI相关新闻,是不是感到信息量爆炸,有效信息少?这么多新产品和新工具,到底哪些是真正是有价值的,哪些只是浮躁的一时热点?想参与AI产品和工具的开发,从哪里能够获得大量的灵感和思路?我会把AI相关的新趋势、新想法、新思路,和成熟AI产品、工具、模型等整理在这里,帮......
  • Python爬虫简易教程
    步骤1.获取编程软件Python3Pycharm社区版(可选,更方便代码编辑)Python软件包requestsselenium requests和selenium的区别对于“xxx.html”类型地址的网页,他们的内容是静态的,这种网站一般不会做防护,可以直接用requests爬。其他类型的内容用selenium更节省时间一点。除......
  • 计算机
    计算机是现代社会不可或缺的工具,它在各个领域发挥着重要的作用。无论是个人使用还是商业应用,计算机都能够提高工作效率,加快信息处理速度,并且为我们带来了许多便利。首先,计算机在通信和信息技术方面起到了重要的作用。随着互联网的普及,人们可以通过电子邮件、社交媒体和即时通讯等方......