文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

CSS3中如何实现倒计时效果

2023-06-08 01:30

关注

小编给大家分享一下CSS3中如何实现倒计时效果,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

实现效果

CSS3中如何实现倒计时效果

实现代码

html

<div class='wrapper'>  <div class='time-part-wrapper'>    <div class='time-part minutes tens'>      <div class='digit-wrapper'>        <span class='digit'>0</span>        <span class='digit'>5</span>        <span class='digit'>4</span>        <span class='digit'>3</span>        <span class='digit'>2</span>        <span class='digit'>1</span>        <span class='digit'>0</span>      </div>    </div>    <div class='time-part minutes ones'>      <div class='digit-wrapper'>        <span class='digit'>0</span>        <span class='digit'>9</span>        <span class='digit'>8</span>        <span class='digit'>7</span>        <span class='digit'>6</span>        <span class='digit'>5</span>        <span class='digit'>4</span>        <span class='digit'>3</span>        <span class='digit'>2</span>        <span class='digit'>1</span>        <span class='digit'>0</span>      </div>    </div>  </div>  <div class='time-part-wrapper'>    <div class='time-part seconds tens'>      <div class='digit-wrapper'>        <span class='digit'>0</span>        <span class='digit'>5</span>        <span class='digit'>4</span>        <span class='digit'>3</span>        <span class='digit'>2</span>        <span class='digit'>1</span>        <span class='digit'>0</span>      </div>    </div>    <div class='time-part seconds ones'>      <div class='digit-wrapper'>        <span class='digit'>0</span>        <span class='digit'>9</span>        <span class='digit'>8</span>        <span class='digit'>7</span>        <span class='digit'>6</span>        <span class='digit'>5</span>        <span class='digit'>4</span>        <span class='digit'>3</span>        <span class='digit'>2</span>        <span class='digit'>1</span>        <span class='digit'>0</span>      </div>    </div>  </div>  <div class='time-part-wrapper'>    <div class='time-part hundredths tens'>      <div class='digit-wrapper'>        <span class='digit'>0</span>        <span class='digit'>9</span>        <span class='digit'>8</span>        <span class='digit'>7</span>        <span class='digit'>6</span>        <span class='digit'>5</span>        <span class='digit'>4</span>        <span class='digit'>3</span>        <span class='digit'>2</span>        <span class='digit'>1</span>        <span class='digit'>0</span>      </div>    </div>    <div class='time-part hundredths ones'>      <div class='digit-wrapper'>        <span class='digit'>0</span>        <span class='digit'>9</span>        <span class='digit'>8</span>        <span class='digit'>7</span>        <span class='digit'>6</span>        <span class='digit'>5</span>        <span class='digit'>4</span>        <span class='digit'>3</span>        <span class='digit'>2</span>        <span class='digit'>1</span>        <span class='digit'>0</span>      </div>    </div>  </div></div>

css

.digit {  display: inline-block;  font-size: 200px;  color: rgba(0, 0, 0, 0.25);  height: 180px;  line-height: 1;}.time-part-wrapper {  display: inline-block;  margin-right: 50px;  position: relative;}.time-part-wrapper:not(:last-child):after {  content: ":";  display: block;  width: 30px;  height: 230px;  position: absolute;  top: 0px;  right: -30px;  color: rgba(0, 0, 0, 0.25);  font-size: 200px;  line-height: 0.9;}.time-part {  width: 140px;  text-align: center;  height: 180px;  overflow: hidden;  display: inline-block;  margin-left: -5px;  box-sizing: border-box;}.time-part .digit-wrapper {  animation-timing-function: cubic-bezier(1, 0, 1, 0);}.time-part.minutes.tens .digit-wrapper {  animation-name: minutes-tens;  animation-duration: 3600s;  animation-iteration-count: 1;}.time-part.minutes.ones .digit-wrapper {  animation-name: minutes-ones;  animation-duration: 600s;  animation-iteration-count: 6;}.time-part.seconds.tens .digit-wrapper {  animation-name: seconds-tens;  animation-duration: 60s;  animation-iteration-count: 60;}.time-part.seconds.ones .digit-wrapper {  animation-name: seconds-ones;  animation-duration: 10s;  animation-iteration-count: 360;}.time-part.hundredths.tens .digit-wrapper {  animation-name: hundredths-tens;  animation-duration: 1s;  animation-iteration-count: 3600;}.time-part.hundredths.ones .digit-wrapper {  animation-name: hundredths-ones;  animation-duration: 0.1s;  animation-iteration-count: 36000;}@keyframes minutes-tens {  0% {    transform: translateY(-180px);  }  16.66667% {    transform: translateY(-360px);  }  33.33333% {    transform: translateY(-540px);  }  50% {    transform: translateY(-720px);  }  66.66667% {    transform: translateY(-900px);  }  83.33333% {    transform: translateY(-1080px);  }}@keyframes minutes-ones {  0% {    transform: translateY(-180px);  }  10% {    transform: translateY(-360px);  }  20% {    transform: translateY(-540px);  }  30% {    transform: translateY(-720px);  }  40% {    transform: translateY(-900px);  }  50% {    transform: translateY(-1080px);  }  60% {    transform: translateY(-1260px);  }  70% {    transform: translateY(-1440px);  }  80% {    transform: translateY(-1620px);  }  90% {    transform: translateY(-1800px);  }}@keyframes seconds-tens {  0% {    transform: translateY(-180px);  }  16.66667% {    transform: translateY(-360px);  }  33.33333% {    transform: translateY(-540px);  }  50% {    transform: translateY(-720px);  }  66.66667% {    transform: translateY(-900px);  }  83.33333% {    transform: translateY(-1080px);  }}@keyframes seconds-ones {  0% {    transform: translateY(-180px);  }  10% {    transform: translateY(-360px);  }  20% {    transform: translateY(-540px);  }  30% {    transform: translateY(-720px);  }  40% {    transform: translateY(-900px);  }  50% {    transform: translateY(-1080px);  }  60% {    transform: translateY(-1260px);  }  70% {    transform: translateY(-1440px);  }  80% {    transform: translateY(-1620px);  }  90% {    transform: translateY(-1800px);  }}@keyframes hundredths-tens {  0% {    transform: translateY(-180px);  }  10% {    transform: translateY(-360px);  }  20% {    transform: translateY(-540px);  }  30% {    transform: translateY(-720px);  }  40% {    transform: translateY(-900px);  }  50% {    transform: translateY(-1080px);  }  60% {    transform: translateY(-1260px);  }  70% {    transform: translateY(-1440px);  }  80% {    transform: translateY(-1620px);  }  90% {    transform: translateY(-1800px);  }}@keyframes hundredths-ones {  0% {    transform: translateY(-180px);  }  10% {    transform: translateY(-360px);  }  20% {    transform: translateY(-540px);  }  30% {    transform: translateY(-720px);  }  40% {    transform: translateY(-900px);  }  50% {    transform: translateY(-1080px);  }  60% {    transform: translateY(-1260px);  }  70% {    transform: translateY(-1440px);  }  80% {    transform: translateY(-1620px);  }  90% {    transform: translateY(-1800px);  }}body {  background: #F1614B;  margin: 0;  font-family: "Aldrich";}.wrapper {  margin: 100px auto;  width: 1000px;  position: relative;}.wrapper:before, .wrapper:after {  content: "";  display: block;  position: absolute;  width: 100%;  left: 0;  height: 20px;  z-index: 10;}.wrapper:before {  top: 0px;  background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2YxNjE0YiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2YxNjE0YiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2dyYWQpIiAvPjwvc3ZnPiA=');  background-size: 100%;  background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #f1614b), color-stop(100%, rgba(241, 97, 75, 0)));  background-image: -moz-linear-gradient(top, #f1614b 0%, rgba(241, 97, 75, 0) 100%);  background-image: -webkit-linear-gradient(top, #f1614b 0%, rgba(241, 97, 75, 0) 100%);  background-image: linear-gradient(to bottom, #f1614b 0%, rgba(241, 97, 75, 0) 100%);}.wrapper:after {  bottom: 0px;  background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2YxNjE0YiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmMTYxNGIiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2dyYWQpIiAvPjwvc3ZnPiA=');  background-size: 100%;  background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(241, 97, 75, 0)), color-stop(100%, #f1614b));  background-image: -moz-linear-gradient(top, rgba(241, 97, 75, 0) 0%, #f1614b 100%);  background-image: -webkit-linear-gradient(top, rgba(241, 97, 75, 0) 0%, #f1614b 100%);  background-image: linear-gradient(to bottom, rgba(241, 97, 75, 0) 0%, #f1614b 100%);}

以上是“CSS3中如何实现倒计时效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯