用CSS3+HTML实现简单的倒计时的代码是什么
Admin 2022-09-19 群英技术资讯 1086 次浏览
这篇文章主要介绍“用CSS3+HTML实现简单的倒计时的代码是什么”的相关知识,下面会通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“用CSS3+HTML实现简单的倒计时的代码是什么”文章能帮助大家解决问题。实现效果
html
%div.wrapper
%div.time-part-wrapper
%div.time-part.minutes.tens
%div.digit-wrapper
%span.digit 0
- (-5..0).each do |i|
%span.digit= -i
%div.time-part.minutes.ones
%div.digit-wrapper
%span.digit 0
- (-9..0).each do |i|
%span.digit= -i
%div.time-part-wrapper
%div.time-part.seconds.tens
%div.digit-wrapper
%span.digit 0
- (-5..0).each do |i|
%span.digit= -i
%div.time-part.seconds.ones
%div.digit-wrapper
%span.digit 0
- (-9..0).each do |i|
%span.digit= -i
%div.time-part-wrapper
%div.time-part.hundredths.tens
%div.digit-wrapper
%span.digit 0
- (-9..0).each do |i|
%span.digit= -i
%div.time-part.hundredths.ones
%div.digit-wrapper
%span.digit 0
- (-9..0).each do |i|
%span.digit= -i
css
@import "compass/css3";
/* Play with speed and easing of the animation */
$one-second: 1s;
$easing: cubic-bezier(1,0,1,0);
/* =========================================== */
@mixin animate($count) {
$step: (100 / $count);
$progress: 0%;
$translate: -$digit-height;
@while $progress < 100 {
#{$progress} { transform: translateY($translate); }
$progress: $progress + $step;
$translate: $translate - $digit-height;
}
}
$digit-height: 180px;
.digit {
display: inline-block;
font-size: 200px;
color: rgba(0,0,0,0.25);
height: $digit-height;
line-height: 1;
}
.time-part-wrapper {
display: inline-block;
margin-right: 50px;
position: relative;
&: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: $digit-height;
overflow: hidden;
display: inline-block;
margin-left: -5px;
box-sizing: border-box;
.digit-wrapper {
animation-timing-function: $easing;
}
&.minutes {
&.tens .digit-wrapper {
animation-name: minutes-tens;
animation-duration: $one-second * 10 * 6 * 10 * 6;
animation-iteration-count: 1;
}
&.ones .digit-wrapper {
animation-name: minutes-ones;
animation-duration: $one-second * 10 * 6 * 10;
animation-iteration-count: 6;
}
}
&.seconds {
&.tens .digit-wrapper {
animation-name: seconds-tens;
animation-duration: $one-second * 10 * 6;
animation-iteration-count: 60;
}
&.ones .digit-wrapper {
animation-name: seconds-ones;
animation-duration: $one-second * 10;
animation-iteration-count: 360;
}
}
&.hundredths {
&.tens .digit-wrapper {
animation-name: hundredths-tens;
animation-duration: $one-second;
animation-iteration-count: 3600;
}
&.ones .digit-wrapper {
animation-name: hundredths-ones;
animation-duration: $one-second / 10;
animation-iteration-count: 36000;
}
}
}
@keyframes minutes-tens {
@include animate(6);
}
@keyframes minutes-ones {
@include animate(10);
}
@keyframes seconds-tens {
@include animate(6);
}
@keyframes seconds-ones {
@include animate(10);
}
@keyframes hundredths-tens {
@include animate(10);
}
@keyframes hundredths-ones {
@include animate(10);
}
body {
background: #F1614B;
margin: 0;
font-family: "Aldrich";
}
.wrapper {
margin: 100px auto;
width: 1000px;
position: relative;
&:before, &:after {
content: "";
display: block;
position: absolute;
width: 100%;
left: 0;
height: 20px;
z-index: 10;
}
&:before {
top: 0px;
@include background-image(linear-gradient(top, rgba(241,97,75,1) 0%,rgba(241,97,75,0) 100%));
}
&:after {
bottom: 0px;
@include background-image(linear-gradient(top, rgba(241,97,75,0) 0%,rgba(241,97,75,1) 100%));
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
CSS元素固定底部有什么实现方法,具体怎样做?在实际项目的操作过程或是学习过程中,不少人都会遇到这样的问题,接下来就让小编带大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
这篇文章给大家分享的是CSS中float属性的相关内容。对于CSS中float属性的使用,有一些朋友是存在疑惑的,下文给大家很详细的介绍了float属性,而且通俗好理解,对大家学习和理解都有帮助,有需要的朋友可以参考,接下来就跟随小编一起了解看看吧。
本文主要给大家分享浮动元素的内容,对于浮动元素的使用可能会出现多种问题,导致后面的布局混乱等等,下面我们就来看看浮动元素常见的问题及解决方法,感兴趣的朋友就继续往下看吧。
使用css怎样做一个伸缩input搜索框效果?在实际的项目中,我们常会遇到搜索框的实现需求,下文实现的搜索框效果是可伸缩的搜索框,实现效果如下,这里会使用到css3+贝塞尔曲线这个效果。
这篇文章主要介绍了浅谈遇到的几个浏览器兼容性问题,详细的介绍了几种我遇到的问题和解决方式,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008