千家信息网

js怎么实现圣诞节倒计时页面特效

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,本文小编为大家详细介绍"js怎么实现圣诞节倒计时页面特效",内容详细,步骤清晰,细节处理妥当,希望这篇"js怎么实现圣诞节倒计时页面特效"文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习
千家信息网最后更新 2026年11月01日js怎么实现圣诞节倒计时页面特效

本文小编为大家详细介绍"js怎么实现圣诞节倒计时页面特效",内容详细,步骤清晰,细节处理妥当,希望这篇"js怎么实现圣诞节倒计时页面特效"文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

实现的代码:

html代码:


Merry Christmas





  • 1




  • 2




  • 3




  • 4




  • 5




  • 6




  • 7




  • 8




  • 9




  • 10




  • 11




  • 12




  • 13




  • 14




  • 15




  • 16




  • 17




  • 18




  • 19




  • 20




  • 21




  • 22




  • 23




  • 24




  • 25




css代码:

body {
background: url("xmas.jpg");
color: #fff;
font-family: 'Oleo Script', cursive;
padding: 20px;
font-weight: 400;
}
h2 {
margin:0;
font-size:75px;
line-height: 75px;
text-align: center;
font-weight: 400;
}
ul {
margin:0 auto 30px auto;
padding:0;
list-style-type:none;
max-width:900px;
width: 100%;
text-align: center;
user-select: none;
}
li {
font-weight: 400;
background-color: #fff;
box-sizing: border-box;
border-radius: 6px;
display: inline-block;
color:#111;
cursor:pointer;
font-size: 26px;
padding:15px;
margin:25px 12px;
width: 130px;
height:130px;
line-height: 100px;
text-align:center;
position: relative;
vertical-align:top;
user-select: none;
perspective: 800px;
transition: all 0.4s ease-in-out;
}
ul li:last-child {
background-size:cover;
display:block;
clear:both;
margin: 20px auto 0 auto;
width: 200px;
height: 275px;
}
ul li:last-child .door {
font-size: 100px;
width: 200px;
height: 275px;
line-height: 240px;
}
ul li:last-child .revealed {
line-height: 123px;
}
.door {
user-select: none;
color:#fff;
font-size: 70px;
position: absolute;
top:0;
left:0;
background-color: #91c1cc;
box-sizing: border-box;
border-top: 2px #eee dashed;
border-right: 2px #eee dashed;
border-bottom: 2px #eee dashed;
border-left: 1px #eee solid;
border-radius: 6px;
padding:15px;
width: 130px;
height:130px;
transform-origin: 0 40%;
transition: all 0.4s ease-in-out;
transform-style: preserve-3d;
}
.current .door {
background-color: #7EAD44;
}
.current .door.open{
color: #7EAD44;
}
.revealed {
user-select: none;
}
#message {
box-sizing: border-box;
color: #222;
display: none;
font-size: 24px;
padding: 20px;
background: #eddecb;
max-width: 500px;
width: 100%;
border-radius: 15px;
margin: 0 auto;
}
.open {
box-shadow: 14px 0px 15px -1px rgba(0,0,0,0.2);
color: #91c1cc;
transform: rotate3d(0, 1, 0, -98deg);
}
.jiggle {
animation: jiggle 0.2s infinite;
transform: rotate(-1deg);
}
@keyframes jiggle {
0% {
transform: rotate(-1deg);
}
50% {
transform: rotate(1deg);
}
}
@media screen and (min-width: 480px) {
li {
margin:25px 20px;
}
}

@media screen and (min-width: 768px) {
body {
background-size:150px;
}
p {
right: 6%;
top: 20%;
bottom: auto;
margin-left: auto;
left: auto;
}
}

js代码:

$(document).ready(function () {
var words = [
'Lorem ',
'ipsum ',
'delor',
'sit',
'amet',
'consect',
'adipisci',
'elit,',
'sed.',
'Eiusmod',
'tempor',
'a',
'enim',
'minim',
'season',
'nulla',
'dolore',
'sint',
'id',
'est',
'laboris',
'ut.',
'aute',
'laborum',
'toe'
];
var message = '';
var date = new Date();
var day = date.getDate();
var month = date.getMonth() + 1;
var scrolled = false;
var timeDelay = 200;
var cardReveal = function () {
$('#message').text(message).show();
};
if (month === 12) {
$('li').each(function (index) {
var adventwindow = index + 1;
var item = $(this);
if (day !== adventwindow && adventwindow < day) {
window.setTimeout(function () {
item.children('.door').addClass('open');
}, timeDelay);
}
timeDelay += 100;
if (adventwindow <= day) {
var word = words[index];
$(this).append('

' + word + '
');
message = message + ' ' + word;
}
if (adventwindow === day) {
$(this).addClass('current');
$(this).addClass('jiggle');
}
$(this).on('click', function () {
if (adventwindow <= day) {
$(this).children('.door').toggleClass('open');
}
$(this).removeClass('jiggle');
if (day >= 25 && adventwindow === 25) {
messageReveal();
if (!scrolled) {
$('html, body').animate({ scrollTop: $('#message').offset().top }, 2000);
scrolled = true;
}
}
});
});
if (day >= 26) {
messageReveal();
}
}
});

读到这里,这篇"js怎么实现圣诞节倒计时页面特效"文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注行业资讯频道。

代码 倒计时 特效 页面 页面特效 文章 内容 妥当 思路 新知 更多 步骤 知识 知识点 篇文章 细节 行业 资讯 资讯频道 跟着 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网黑科技 互联网高科技 湖南永感互联网科技有限公司 北京路客互联网科技有限公司 科技和互联网公司 深圳互联网科技公司 银优互联网科技有限公司 腾讯科技 互联网女皇 互联网科技公司招聘 互联网汽车科技小镇 茂名市互联网科技产业园 互联网科技和信息 国大互联网教育科技有限公司工作 互联网相关科技技术 宇信科技在杭州互联网排第几 昆明中奇联合互联网科技 科技互联网行业投资研究 中国科技和美国互联网 互联网企业和网络科技有限公司 六子台科技互联网展会 百单网互联网科技有限公司 互联网是第几次科技革命的成果 九亚互联网科技 互联网科技美容 深圳前海聚择互联网科技有限公司 贵州叶脉互联网科技有限公司所属行业 想开互联网科技公司怎么样 每天都有哪些好的互联网科技 郑州欣桑互联网科技有限公司 现代互联网科技公司
0