HTML编写计算器样式

HTML编写计算器样式

代码如下
方法1:使用table方法

<!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>
</head>
<body>
    <table style= "width: 230px;height: 320px;text-align: center; font-size: 20px;color: white;">
    <tr>
        <td colspan="4" style="background-color: rgb(129, 127, 127);text-align: right;border-top-left-radius: 15px;  border-top-right-radius: 15px;">0</td>
    </tr>
    <tr style="background-color: rgb(129, 127, 127);">
        <td width="25%">AC</td>
        <td width="25%">+/-</td>
        <td width="25%">%</td>
        <td width="25%" style="background-color: sandybrown;">÷</td>
    </tr>
    <tr style="background-color: rgb(129, 127, 127);">
        <td>7</td>
        <td>8</td>
        <td>9</td>
        <td style="background-color: sandybrown;">*</td>
    </tr>
    <tr style="background-color: rgb(129, 127, 127);">
        <td>4</td>
        <td>5</td>
        <td>6</td>
        <td style="background-color: sandybrown;">-</td>
    </tr>
    <tr style="background-color: rgb(129, 127, 127);">
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td style="background-color: sandybrown;">+</td>
    </tr>
    <tr style="background-color: rgb(129, 127, 127);">
        <td colspan="2" style="border-bottom-left-radius: 15px;">0</td>
        <td>.</td>
        <td style="background-color: sandybrown;border-bottom-right-radius: 15px;">=</td>
    </tr>
</table>
</body>
</html>

实现效果
在这里插入图片描述
方法二:使用div方法

<!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>
</head>
<style>
.out{
width: 360px;
height: 420px;
/* border: burlywood solid 1px; */
margin: auto;
margin-top: 100px;
    }
    .frame{
        width: 360px;
height: 120px;
/* border: burlywood solid 1px; */
margin: auto;
background-color: rgb(90, 100, 99);
font-size: 30px;
color: honeydew;
text-align: right;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
        
    }

    .red{
        width: 10px;
        height: 10px;
        border-radius: 50%;
        margin-left: 10px;
        margin-top: 10px;
        background-color: red;
        float: left;
}
.red:hover{

    background-color: rgb(43, 29, 29);

}
.bule{
    width: 10px;
        height: 10px;
        border-radius: 50%;
        margin-left: 10px;
        margin-top: 10px;
    background-color: rgb(28, 28, 219);
    float: left;
}
.bule:hover{

background-color: rgb(17, 156, 149);

}
.green{
    width: 10px;
        height: 10px;
        border-radius: 50%;
        margin-left: 10px;
        margin-top: 10px;
    background-color: green;
    float: left;
}
.green:hover{

background-color: rgb(187, 98, 38);

}
    
    .down{
        width: 360px;
height: 300px;
/* border: burlywood solid 1px; */
margin: auto;
background-color: rgb(93, 105, 103);
border-bottom-right-radius: 15px;
border-bottom-left-radius: 15px;
    }
    .box{
        width: 88px;
height: 58px;
border: rgb(222, 233, 225) solid 1px;
float: left;
text-align: center;
font-size: 25px;
color: honeydew;
    }
    .yell{
background-color: chocolate;

    }
    .gray{
background-color: gray;
    }
</style>
<body>
    <div class="out">
        <div class="frame">

            <div >
                <div class="red"></div>
                <div class="bule"></div>
                <div class="green"></div>
                计算器
            </div>
           </div>
        <div class="down gray">
            <div class="box">AC</div>
            <div class="box">C</div>
            <div class="box">+/-</div>
            <div class="box yell">%</div>
            <div class="box">7</div>
            <div class="box">8</div>
            <div class="box">9</div>
            <div class="box yell">+</div>
            <div class="box">4</div>
            <div class="box">5</div>
            <div class="box">6</div>
            <div class="box yell">-</div>
            <div class="box">1</div>
            <div class="box">2</div>
            <div class="box">3</div>
            <div class="box yell">*</div>
            <div class="box" style="width: 49%;" >0</div>
            <div class="box">.</div>
            <div class="box yell" style="border-bottom-right-radius: 15px;">=</div>
        </div>
    </div>
</body>
</html>

实现结果:小圆点可以实现变色
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苏同学的安全屋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值