倒计时 css,CSS倒计时时钟

css

/* Play with speed and easing of the animation */

/* =========================================== */

.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%);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,你可以使用 HTML、CSS 和 JavaScript 实现时钟翻牌器倒计时效果。以下是一个简单的实现示例: HTML 代码: ```html <div class="flip-clock"> <div class="flip-clock__days flip-clock__part"></div> <div class="flip-clock__hours flip-clock__part"></div> <div class="flip-clock__minutes flip-clock__part"></div> <div class="flip-clock__seconds flip-clock__part"></div> </div> ``` CSS 代码: ```css .flip-clock { display: flex; justify-content: center; align-items: center; height: 100px; } .flip-clock__part { display: flex; flex-direction: row-reverse; } .flip-clock__part > * { position: relative; width: 40px; height: 50px; margin-right: -5px; transform-origin: bottom center; font-size: 36px; font-weight: bold; color: #fff; background-color: #000; } .flip-clock__part > * > * { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center; font-size: 16px; font-weight: normal; color: #000; background-color: #fff; transform: rotateX(0deg); transition: transform 0.5s; } .flip-clock__part > * > *:last-child { transform: rotateX(-180deg); } ``` JavaScript 代码: ```javascript function updateClock(endtime) { const total = Date.parse(endtime) - Date.parse(new Date()); const seconds = Math.floor((total / 1000) % 60); const minutes = Math.floor((total / 1000 / 60) % 60); const hours = Math.floor((total / (1000 * 60 * 60)) % 24); const days = Math.floor(total / (1000 * 60 * 60 * 24)); document.querySelector('.flip-clock__days').innerHTML = pad(days, 2); document.querySelector('.flip-clock__hours').innerHTML = pad(hours, 2); document.querySelector('.flip-clock__minutes').innerHTML = pad(minutes, 2); document.querySelector('.flip-clock__seconds').innerHTML = pad(seconds, 2); } function pad(num, size) { let s = num + ''; while (s.length < size) s = '0' + s; return s; } const endTime = new Date('2021-12-31T23:59:59'); setInterval(() => updateClock(endTime), 1000); ``` 在这个示例中,我们使用了一个名为 `flip-clock` 的容器来包含四个翻牌器元素,分别表示天、小时、分钟和秒。每个翻牌器元素都由两个子元素组成,一个用于显示当前值,另一个用于显示下一个值。我们使用 CSS 的 3D 转换效果来实现翻牌器的动画效果。在 JavaScript 中,我们使用 `setInterval` 函数来更新翻牌器的值,并将其格式化为两位数字。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值