htmltest~计算器界面的实现

通过div+css和部分布局的作用,实现了,如下效果的计算器展示页面

![C%]R$IGDK4J(%3LJXD3]SY.png

,废话不多说,最主要的还是分享代码:

html:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/counter.css">
</head>
<body>
    .<div class="counter-body">
        <div class="counter-title">
            <div>计算器</div>
            <div>-</div>
            <div>                口            </div>
            <div>X</div>
        </div>
        <div class="counter-content">
            <div class="counter-content-title">
                <div class="content-title">
                    <div>编辑(E)</div>
                    <div>查看(V)</div>
                    <div>帮助(H)</div>
                </div>
            </div>
            <div class="counter-content-input">
                <input  placeholder="0." type="text">
            </div>
            <div class="counter-content-btn-row">
                <div class="counter-content-btn-col1">
                    <div> </div>
                    <div>Backspace</div>
                    <div>CE</div>
                    <div>C</div>
                </div>
                <div class="counter-content-btn-col">
                    <div>MC</div>
                    <div>7</div>
                    <div>8</div>
                    <div>9</div>
                    <div>/</div>
                    <div>sqrt</div>
                </div>
                <div class="counter-content-btn-col">
                    <div>MR</div>
                    <div>4</div>
                    <div>5</div>
                    <div>6</div>
                    <div>*</div>
                    <div>%</div>
                </div>
                <div class="counter-content-btn-col">
                    <div>MS</div>
                    <div>1</div>
                    <div>2</div>
                    <div>3</div>
                    <div>-</div>
                    <div>1/x</div>
                </div>
                <div class="counter-content-btn-col">
                    <div>M+</div>
                    <div>0</div>
                    <div>+/-</div>
                    <div>.</div>
                    <div>+</div>
                    <div>=</div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

css样式表:
body{
    margin: 0 auto;
}
.counter-body{
    position: absolute;
    top: 200px;
    left: 200px;
    border: 2px solid #3335e5;
    width: 245px;
    height: 210px;
    border-radius: 5px;
    background: rgba(217, 217, 217, 0.49);
}
.counter-title{
    line-height: 26px;
    width: 100%;
    background: #3335e5;
    color:#fff;
}
.counter-title div{
    display: inline-block;
}
.counter-title div:first-child{
    margin-right: 70px;
}
.counter-title div:nth-child(4){
    background: red;
}
.counter-title div:nth-child(2){
    font-size: 18px;
}
.counter-title div:nth-child(2),.counter-title div:nth-child(4){
    padding-left: 9px;
    padding-right: 9px;
}
.counter-title div:nth-child(2),.counter-title div:nth-child(3),.counter-title div:nth-child(4){
    border-radius: 2px;
    height: 22px;
    border: 1px solid #FFFFFF;
}
.counter-title div{
    padding: 0 6px 2px 6px;
}
.content-title {
    display: table;
}
.content-title div{
    padding-left: 10px;
    text-align: center;
    line-height: 22px;
    display: table-cell;
    font-size: 12px;
}
.counter-content-input{
    padding-left: 10px;
}
.counter-content-input input{
    height: 15px;
    text-align: right;
    width: 220px;
}
.counter-content-btn-row{
    vertical-align: middle;
    margin-top: -15px;
    padding: 25px 10px;
}
.counter-content-btn-col1 div:first-child{
    background: rgba(247, 247, 247, 0.87);
    text-shadow: 5px 5px 3px #bfbfbf   ;
    color: #fff;
    width: 16px;
    line-height: 15px;
}
.counter-content-btn-col1 div:nth-child(2){
    background: rgba(247, 247, 247, 0.87);
    width: 65px;
    padding: 1px 1px;
}
.counter-content-btn-col1 div{
    color: red;
    background: rgba(247, 247, 247, 0.87);
    padding: 1px 1px;
    height: 15px;
    border-radius: 2px;
    text-align: center;
    display: inline-block;
    font-size: 10px;
    margin:  0 1.5px;
    border: 1px solid #858585;
    width: 46px;
}
.counter-content-btn-row div:nth-child(2),.counter-content-btn-row div:nth-child(3),.counter-content-btn-row div:nth-child(4){
    color: blue;
}
.counter-content-btn-row div:nth-child(4n+1){
    color: red;
}
.counter-content-btn-col div:first-child{
    background: rgba(247, 247, 247, 0.87);
    margin-right: 4px;
}
.counter-content-btn-col div{
    background: rgba(247, 247, 247, 0.87);
    display: inline-block;
    border-radius: 2px;
    text-align: center;
    display: inline-block;
    font-size: 10px;
    margin:  0 2px;
    border: 1px solid #858585;
    width: 24.38px;
    height: 15px;
}
.counter-content-btn-col1,.counter-content-btn-col{
    color: red;
    line-height: 15px;
    margin: 1.5px 0 ;
}
.counter-content-btn-col div:last-child{
    width: 25px;
}
复制代码

其中,

在这个部分实现的时候出现一个小问题就是有个前边儿的无字小方框,本来是一个空格就可以搞定,但是由于空格撑不起来,所以在div相应的部分加入了空格&nbsp

 
这个应该是或是这次实现过程中出现的一个小问题吧, 另外说一点,在这次实现的过程中用到了很多伪类选择器 也相当于是对伪类选择器的一次练手吧

加油吧~~~ fighting~@^-^@~

转载于:https://juejin.im/post/5a3229dff265da432d281eb7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值