html 计算器界面

这篇具有很好参考价值的文章主要介绍了html 计算器界面。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

其他链接:
https://www.freecodecamp.org/news/how-to-build-an-html-calculator-app-from-scratch-using-javascript-4454b8714b98/
https://codepen.io/pen/tour/welcome/start

html 计算器界面,杂七杂八,html,前端

下面展示一些 内联代码片文章来源地址https://www.toymoban.com/news/detail-646017.html

<!DOCTYPE html>
<html lang="en">
    <!--
    https://www.freecodecamp.org/news/how-to-build-an-html-calculator-app-from-scratch-using-javascript-4454b8714b98/ 
    https://codepen.io/pen/tour/welcome/start 
    -->
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* // NOTE: You don't need to mess around with 
        // CSS to follow the tutorial. Focus on the 
        // JavaScript instead!
        // =========================

        // Some personal resets */
            html {
                box-sizing: border-box;
            }

            *,
            *::before,
            *::after {
            box-sizing: inherit;
            }

            body {
            margin: 0;
            }

            /* Responsive Images */
            embed,
            iframe,
            img,
            object,
            video {
                max-width: 100%;
            }

            h1,
            h2,
            h3,
            h4,
            h5,
            h6,
            ul,
            ol,
            li,
            p,
            pre,
            blockquote,
            figure,
            hr {
                margin: 0;
                padding-right: 0;
                padding-left: 0;
            }

            a {
                text-decoration: none;
            }

            a:focus {
                outline: none;
            }

            h1,
            h2,
            h3,
            h4,
            h5,
            h6 {
                display: block;
            }

            /* Removes all decimals and discs from lists */
            ol,
            ul {
                list-style: none;
            }

            /* 
            * Completely resets form items
            * ----------------------------
            * Super hard reset that removes all borders
            * and radiuses of all form items (including
            * checkboxes and radios)
            */

            input,
            textarea,
            button {
                border: 0;
                border-radius: 0;
                background-color: transparent;
                font-size: inherit;
                font-family: inherit;
                font-weight: inherit;
                outline: none;
                appearance: none;
                text-align: left;
            }

            input:hover,
            input:active,
            input:focus,
            textarea:hover,
            textarea:active,
            textarea:focus,
            button:hover,
            button:active,
            button:focus {
            outline: none;
            }

            :root {
                font-family: Helvetica, Arial, sans-serif;
            }

            html {
                font-size: 175%;
                font-weight: 300;
                line-height: 1.3;
            }

            body {
                align-items: center;
                background-image: linear-gradient(236deg, #74ebd5, #acb6e5);
                display: flex;
                height: 100vh;
                justify-content: center;
            }

            .container {
                max-width: 20em;
            }

            .container > p {
                text-align: center;
            }

            .calculator {
                border-radius: 12px;
                box-shadow: 0 0 40px 0px rgba(0, 0, 0, 0.15);
                margin-left: auto;
                margin-right: auto;
                margin-top: 2em;
                max-width: 15em;
                overflow: hidden;
            }

            .calculator__display {
                background-color: #222222;
                color: #fff;
                font-size: 1.714285714em;
                padding: 0.5em 0.75em;
                text-align: right;
            }

            .calculator__keys {
                background-color: #999;
                display: grid;
                grid-gap: 1px;
                grid-template-columns: repeat(4, 1fr);
            }

            .calculator__keys > * {
                background-color: #fff;
                padding: 0.5em 1.25em;
                position: relative;
                text-align: center;
            }

            .calculator__keys > *:active::before,
            .calculator__keys > .is-depressed::before {
                background-color: rgba(0, 0, 0, 0.2);
                bottom: 0;
                box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.5) inset;
                content: "";
                left: 0;
                opacity: 0.3;
                position: absolute;
                right: 0;
                top: 0;
                z-index: 1;
            }

            .key--operator {
                background-color: #eee;
            }

            .key--equal {
                background-image: linear-gradient(to bottom, #fe886a, #ff7033);
                grid-column: -2;
                grid-row: 2 / span 4;
            }

    </style>
</head>
<body>
    
    <div class="container">
        
        <div class="calculator">
          <div class="calculator__display">0</div>
    
          <div class="calculator__keys">
            <button class="key--operator" data-action="add">+</button>
            <button class="key--operator" data-action="subtract">-</button>
            <button class="key--operator" data-action="multiply">&times;</button>
            <button class="key--operator" data-action="divide">÷</button>
            <button>7</button>
            <button>8</button>
            <button>9</button>
            <button>4</button>
            <button>5</button>
            <button>6</button>
            <button>1</button>
            <button>2</button>
            <button>3</button>
            <button>0</button>
            <button data-action="decimal">.</button>
            <button data-action="clear">AC</button>
            <button class="key--equal" data-action="calculate">=</button>
          </div>
        </div>
      </div>


      <script>
        console.log("start");
        const calculator = document.querySelector('.calculator');
        console.log(calculator);
        const keys = calculator.querySelector('.calculator__keys');


        keys.addEventListener('click', e => {
            if (e.target.matches('button')) {
                // Do something
                const key = e.target  
                const action = key.dataset.action  // 得到动作  +-*/

                // 如果不是action,则是数字
                if (!action) {
                    console.log('number key!')
                }

                if (
                    action === 'add' ||
                    action === 'subtract' ||
                    action === 'multiply' ||
                    action === 'divide'
                ) {
                console.log('operator key!')
                }
            }
        })

    </script>
</div>

</body>
</html>

到了这里,关于html 计算器界面的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • rpc入门笔记 0x02 protobuf的杂七杂八

    安装grpcio和grpcio-tools库 生成proto的python文件 python -m grpc_tools.protoc :使用grpc_tools包中的protoc命令进行代码生成。 --python_out=. :指定生成的Python代码的存放位置为当前目录。 --grpc_python_out=. :指定生成的gRPC代码的存放位置为当前目录。 -I. :指定搜索.proto文件的路径为当前目录

    2024年02月08日
    浏览(46)
  • html 计算器界面

    其他链接: https://www.freecodecamp.org/news/how-to-build-an-html-calculator-app-from-scratch-using-javascript-4454b8714b98/ https://codepen.io/pen/tour/welcome/start 下面展示一些 内联代码片 。

    2024年02月13日
    浏览(45)
  • 图形界面科学计算器 功能:用户界面模拟真实计算器(具体可参考手机计算器APP),显示0~9按键、+、-、*、/运算符和小数点、=、(),按下对应按键,算式区域(可用Label组件)显示用户输入的内容,

    图形界面科学计算器 功能:用户界面模拟真实计算器(具体可参考手机计算器APP),显示0~9按键、+、-、*、/运算符和小数点、=、(),按下对应按键,算式区域(可用Label组件)显示用户输入的内容,按等号,计算结果并显示。 要求: 1.采用图形用户界面 2.正常输入算式,

    2024年02月03日
    浏览(37)
  • python界面开发案例:制作一个计算器软件

    前言 大家早好、午好、晚好吖 ❤ ~欢迎光临本文章 在我们手机上大家都有一个计算器,对吧 那它这功能是怎么实现的呢? 今天我们在电脑上来实现一个电脑端计算器界面~ 开发环境: Python 3.8 / 编译器 Pycharm 2021.2版本 / 编辑器 本文所有模块环境源码教程皆可点击文章下方

    2023年04月16日
    浏览(39)
  • HTML程序大全(1):简易计算器

    HTML代码,主要创建了几个按钮。 CSS代码,主要设置了背景、计算机板和按钮等等的颜色。 javascript代码,主要设置了对应按钮按下的显示、计算、清零的工作。 总结: 这是一个简单的计算器,使用HTML、CSS和JavaScript实现。HTML代码创建了一个计算器的界面,CSS代码设置了计算

    2024年02月04日
    浏览(29)
  • MATLAB GUI图形化界面设计计算器

    MATLAB GUI界面设计教程可以帮助用户创建交互式的图形用户界面,以简化与MATLAB程序的交互过程。以下是一个简化的教程,指导你如何进行MATLAB GUI界面设计: 1. 启动GUIDE或App Designer GUIDE :在MATLAB命令窗口中输入 guide 命令,然后按Enter键启动GUIDE。 App Designer :在MATLAB的“Apps”

    2024年04月23日
    浏览(39)
  • 学会使用Android Studio网格布局制作计算器界面

    1.1GridLayout布局使用虚细线将布局划分为行、列和单元格,也支持一个控件在行、列上都有交错排列。 1.2可以自己设置布局中组件的排列方式 1.3可以自定义网格布局有多少行、多少列 1.4可以直接设置组件位于某行某列 1.5可以设置组件横跨几行或者几列 基于-  Empty Activity 模板

    2024年02月08日
    浏览(37)
  • HTML和JavaScript实现一个简单的计算器

    使用HTML和JavaScript实现一个简单的计算器。 这段代码会在浏览器中创建一个标题为\\\"Simple Calculator\\\"的页面。页面顶部有一个 h1 元素,用于显示标题。计算器界面使用了CSS网格布局,将按钮排列为4列。 在JavaScript部分,定义了一些函数来处理计算器的操作。 appendCharacter() 函数用

    2024年02月13日
    浏览(32)
  • HTML+CSS+JS+Django 实现前后端分离的科学计算器、利率计算器(附全部代码在gitcode链接)

    本次作业完成了 全部的基础功能 和附件功能1. 前端修改利率表 2. 科学计算 3. 页面原型设计 以及扩展功能1. 动态按钮,动态背景,页面局部or全局切换等等。 这个作业属于哪个课程 2301-计算机学院-软件工程 这个作业要求在哪里 软工实践第二次作业 这个作业的目标 实现一个

    2024年02月08日
    浏览(30)
  • 用JavaScript和HTML实现一个精美的计算器

    计算器是我们日常生活中经常使用的工具之一,可以帮助我们进行简单的数学运算。在本博文中,我将使用JavaScript编写一个漂亮的计算器,并添加加减乘除功能。这个计算器将有一个精美的用户界面,包含9个数字按钮和加减乘除操作符。 HTML:负责构建界面 CSS:负责美化界

    2024年02月15日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包