用html,script和dom知识实现电子倒计时

25 篇文章 0 订阅
2 篇文章 0 订阅

1:body部分:

<div class="container">
        <h1>过年倒计时</h1>
        <section>
            <div class="item">
                <p id="day">100</p>
                <p>天数</p>
            </div>
            <div class="item">
                <p id="hour">10</p>
                <p>小时</p>
            </div>
            <div class="item">
                <p id="min">10</p>
                <p>分钟</p>
            </div>
            <div class="item">
                <p id="sec">10</p>
                <p>秒数</p>
            </div>
        </section>
    </div>

2:css样式:让倒计时一直处于页面中央,无论页面大小如何变化(运用弹性布局比较简单)

<style>
 body {
            height: 100vh;
            background-image: url(img/2.jpg);
            background-size: cover;
            background-position: center center;//让背景图片一直中心居中
        }

        .container {
            height: 100%;
            background-color: rgba(0, 0, 0, .5);//阴影效果
            display: flex;       //弹性盒
            justify-content: center;//让弹性盒子在x轴上,居中对齐,写在父级,作用于子级
            align-self: center;
            align-content: center;
        }

        h1, [id] {     //群组选择器
            width: 100%;
            text-align: center;
        }

        section {
            display: flex;
            justify-content: center;
        }

        .item {
            margin: 10px; 
        }

     
    </style>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值