当前位置: 首页 > news >正文

沈阳做网站seo广告公司名字

沈阳做网站seo,广告公司名字,0基础学做网站,柳州网站建设11博主主页:技术分享菌 博主简介:专注于前端开发领域,旨在帮助初学者提升前端技能水平,分享技术资讯和实用教程。内容涵盖 HTML、CSS、JavaScript、前端框架(如 React、Vue、Angular 等)以及前端工程化等方面…

博主主页:技术分享菌

博主简介:专注于前端开发领域,旨在帮助初学者提升前端技能水平,分享技术资讯和实用教程。内容涵盖 HTML、CSS、JavaScript、前端框架(如 React、Vue、Angular 等)以及前端工程化等方面。我们将不断更新优质内容,为大家提供一场前端技术的盛宴,欢迎你的关注和参与。

文章目录

前言

一、倒计时 倒数日是什么?

二、功能实现

(一)、倒数日

1. 效果图展示

2. HTML 部分

3. CSS 部分

4. JS 部分

5. 整体代码

(二)、倒计时

1.效果图展示

2. HTML部分

3. CSS部分 

4. JS部分

5. 整体代码

总结


前言

在日常生活和各种场景中,倒数日、倒计时可以帮助我们更好地规划时间、提高工作效率、激发紧迫感等。在互联网领域,倒数日功能也被广泛应用于各类倒计时应用,如:活动促销、比赛倒计时、课程预约等。


一、倒计时 倒数日是什么?

倒数日、倒计时(Countdown)是一种常见的时间展示方式,用于提醒用户某个重要事件即将到来。在日常生活和各种场景中,倒计时可以帮助人们更好地规划时间、提高工作效率、激发紧迫感等。随着互联网技术的发展,倒计时功能在网页设计中变得越来越常见,如:活动促销、比赛倒计时、课程预约等。

二、功能实现

(一)、倒数日

1. 效果图展示

2. HTML 部分

代码如下(示例):

<!DOCTYPE html>
<html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>倒数日</title>
</head><body><div class="countdown"><div class="title">距离<span>春节</span>还有</div><div class="day"><strong id="days">5000</strong> <span>天</span></div><div class="target">目标日:<span id="goal">2025-01-01</span></div></div>
</body></html>

3. CSS 部分

代码如下(示例):

* {margin: 0;padding: 0;}body {background: -webkit-linear-gradient(to right, #FFFDE4, #005AA7);background: linear-gradient(to right, #FFFDE4, #005AA7);}.countdown {margin: 50px auto;width: 400px;height: 450px;background-color: rgb(145, 3, 3);background-image: url(./festival.jpg);background-size: cover;}.countdown .title {width: 100%;height: 100px;text-align: center;line-height: 100px;font-size: 24px;color: white;}.countdown .day {width: 100%;height: 250px;line-height: 250px;text-align: center;color: white;}.countdown .day strong {display: inline-block;padding: 15px;height: 100px;line-height: 100px;background-color: black;font-size: 72px;}.countdown .day span {font-size: 36px;}.countdown .target {height: 100px;line-height: 100px;text-align: center;color: white;}

对CSS部分代码进行说明解释

countdown类中 我写 背景颜色 和 背景图,你们拿到代码就只显示背景色

如需要背景图,点击百度网盘链接:网页图片资源

4. JS 部分

 // 函数封装 getCountTimefunction getCountTime() {// 1. 获得当前时间戳const now = +new Date()// 2. 得到将来的时间戳const time = '2024-01-01'   //目标时间修改处const after = +new Date(time)// console.log(now,after);// 时间戳是毫秒// 3. 将得到剩余的时间戳 sec 记得转换成 秒数const sec = (after - now) / 1000// 4. 转换为 天数cosnt d = parseInt(sec / 60 / 60 / 24)  //   计算天数// console.log(h,m,s);document.querySelector('.title span').innerHTML = '元旦'   //修改标题处document.querySelector('#days').innerHTML = ddocument.querySelector('#goal').innerHTML = time}// 先调用一次getCountTime()// 开启定时器setInterval(getCountTime, 1000)

对JS部分代码进行说明解释

如需要修改目标时间 、标题,找到对应的注释代码

时间戳是毫秒,需要转换为秒数  公式: 秒数 = 毫秒 / 1000

计算天数 公式

 cosnt d = parseInt(总秒数 / 60 / 60 / 24) 

5. 整体代码

<!DOCTYPE html>
<html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>倒数日</title><style>* {margin: 0;padding: 0;}body {background: -webkit-linear-gradient(to right, #FFFDE4, #005AA7);background: linear-gradient(to right, #FFFDE4, #005AA7);}.countdown {margin: 50px auto;width: 400px;height: 450px;background-color: rgb(145, 3, 3);background-image: url(./festival.jpg);background-size: cover;}.countdown .title {width: 100%;height: 100px;text-align: center;line-height: 100px;font-size: 24px;color: white;}.countdown .day {width: 100%;height: 250px;line-height: 250px;text-align: center;color: white;}.countdown .day strong {display: inline-block;padding: 15px;height: 100px;line-height: 100px;background-color: black;font-size: 72px;}.countdown .day span {font-size: 36px;}.countdown .target {height: 100px;line-height: 100px;text-align: center;color: white;}</style>
</head><body><div class="countdown"><div class="title">距离<span>春节</span>还有</div><div class="day"><strong id="days">5000</strong> <span>天</span></div><div class="target">目标日:<span id="goal">2025-01-01</span></div></div><script>// 函数封装 getCountTimefunction getCountTime() {// 1. 获得当前时间戳const now = +new Date()// 2. 得到将来的时间戳const time = '2024-01-01'   //目标时间修改处const after = +new Date(time)// console.log(now,after);// 3. 将得到剩余的时间戳 sec 记得转换成 秒数const sec = (after - now) / 1000// 4. 转换为 天数const d = parseInt(sec / 60 / 60 / 24)  //   计算天数// console.log(h,m,s);document.querySelector('.title span').innerHTML = '元旦'   //修改标题处document.querySelector('#days').innerHTML = ddocument.querySelector('#goal').innerHTML = time}// 先调用一次getCountTime()// 开启定时器setInterval(getCountTime, 1000)</script>
</body></html>

(二)、倒计时

1.效果图展示

        图1 实际效果图                                                                  图2 时间过去后效果图

2. HTML 部分

代码如下(示例):

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>倒计时</title>
</head><body><div class="countdown"><p class="next">今天是2023年11月11日</p><p class="title">下班倒计时</p><p class="clock"><span id="hour">00</span><i>:</i><span id="minutes">25</span><i>:</i><span id="scond">20</span></p><p class="tips"><span>23:30:00</span> 下班</p></div>
</body></html>

3. CSS 部分 

.countdown {width: 240px;height: 305px;text-align: center;line-height: 1;color: #fff;background-color: brown;overflow: hidden;}.countdown .next {font-size: 16px;margin: 25px 0 14px;}.countdown .title {font-size: 33px;}.countdown .tips {margin-top: 80px;font-size: 22px;}.countdown small {font-size: 17px;}.countdown .clock {width: 142px;margin: 18px auto 0;overflow: hidden;}.countdown .clock span,.countdown .clock i {display: block;text-align: center;line-height: 34px;font-size: 23px;float: left;}.countdown .clock span {width: 34px;height: 34px;border-radius: 2px;background-color: #303430;}.countdown .clock i {width: 20px;font-style: normal;}

4. JS 部分

// 日期函数封装 getMyDateconst today = document.querySelector('.countdown .next')function getMyDate() {const date = new Date()return `今天是 ${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`}today.innerHTML = getMyDate()// 函数封装 getCountTimefunction getCountTime() {// 1. 获得当前时间const now = +new Date()// 2. 得到将来的时间戳const time = '21:30' // 修改时间处const after = +new Date('2050-11-15 '+time) //修改日期处// console.log(now,after);// 3. 将得到剩余的时间戳 sec 记得转换成 秒数const sec = (after - now) / 1000// 4. 转换为 时分秒let h = parseInt(sec / 60 / 60 % 24)let m = parseInt(sec / 60 % 60)let s = parseInt(sec % 60)// 当小于10 需要补0h = h < 10 ? '0' + h : hm = m < 10 ? '0' + m : ms = s < 10 ? '0' + s : s// console.log(h,m,s);document.querySelector('#hour').innerHTML = hdocument.querySelector('#minutes').innerHTML = mdocument.querySelector('#scond').innerHTML = sdocument.querySelector('.tips span').innerHTML = time}// 先调用一次getCountTime()// 开启定时器setInterval(getCountTime, 1000)

对JS部分代码进行说明解释

如需要修改时间 、日期,找到对应的注释代码

倒计时核心代码  封装 getCountTime 函数

时间戳是毫秒,需要转换为秒数  公式: 秒数 = 毫秒 / 1000

计算时、分、秒 公式

h = parseInt(总秒数 / 60 / 60 % 24)   //   计算小时

m = parseInt(总秒数 / 60 % 60);     //   计算分数

s = parseInt(总秒数 % 60);       //   计算秒数

时分秒 需要进行判断操作

用简洁的三元运算符进行判断 如小于10 就需要进行补0  字符串拼接操作

5. 整体代码

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>倒计时</title><style>.countdown {width: 240px;height: 305px;text-align: center;line-height: 1;color: #fff;background-color: brown;overflow: hidden;}.countdown .next {font-size: 16px;margin: 25px 0 14px;}.countdown .title {font-size: 33px;}.countdown .tips {margin-top: 80px;font-size: 22px;}.countdown small {font-size: 17px;}.countdown .clock {width: 142px;margin: 18px auto 0;overflow: hidden;}.countdown .clock span,.countdown .clock i {display: block;text-align: center;line-height: 34px;font-size: 23px;float: left;}.countdown .clock span {width: 34px;height: 34px;border-radius: 2px;background-color: #303430;}.countdown .clock i {width: 20px;font-style: normal;}</style>
</head><body><div class="countdown"><p class="next">今天是2023年11月15日</p><p class="title">下班倒计时</p><p class="clock"><span id="hour">00</span><i>:</i><span id="minutes">25</span><i>:</i><span id="scond">20</span></p><p class="tips"><span>23:30:00</span> 下班</p></div><script>// 日期函数封装 getMyDateconst today = document.querySelector('.countdown .next')function getMyDate() {const date = new Date()return `今天是 ${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`}today.innerHTML = getMyDate()// 函数封装 getCountTimefunction getCountTime() {// 1. 获得当前时间const now = +new Date()// 2. 得到将来的时间戳const time = '21:30' // 修改时间日期处const after = +new Date('2050-11-15 '+time)// console.log(now,after);// 3. 将得到剩余的时间戳 sec 记得转换成 秒数const sec = (after - now) / 1000// 4. 转换为 时分秒let h = parseInt(sec / 60 / 60 % 24)let m = parseInt(sec / 60 % 60)let s = parseInt(sec % 60)// 当小于10 需要补0h = h < 10 ? '0' + h : hm = m < 10 ? '0' + m : ms = s < 10 ? '0' + s : s// console.log(h,m,s);document.querySelector('#hour').innerHTML = hdocument.querySelector('#minutes').innerHTML = mdocument.querySelector('#scond').innerHTML = sdocument.querySelector('.tips span').innerHTML = time}// 先调用一次getCountTime()// 开启定时器setInterval(getCountTime, 1000)</script>
</body></html>

总结

以上就是今天要讲的内容,本文仅仅简单介绍了日期对象,时间戳在实际开发使用,而Date对象提供了大量能使我们快速处理数据的方法。在日常生活和各种场景中,倒计时,倒数日可以帮助人们更好地规划时间、提高工作效率、激发紧迫感等。随着互联网技术的发展,倒计时功能在网页设计中变得越来越常见。

http://www.hrbkazy.com/news/8434.html

相关文章:

  • 德州网站制作公司电子商务平台有哪些
  • a做爰网站seo网站排名优化软件是什么
  • 电影网站怎么做laravel培训机构加盟店排行榜
  • 线上学编程哪个机构比较好丹东网站seo
  • 新时期如何做好政府网站建设网站应该如何推广
  • ag网站开发网站制作的流程是什么
  • 商丘做网站多少钱百度一下电脑版首页网址
  • 建设集团网站报告书万能推广app
  • 网址导航是ie浏览器吗seo网站编辑优化招聘
  • 有没有专门做包装设计的网站国际新闻界期刊
  • 珠海营销型网站哪家好自己建个网站要多少钱
  • 昆明住房和城乡建设部网站网络营销的基本流程
  • cms网站下载seo任务
  • 做爰全过程免费狐狸网站网络营销的基本特征
  • 汕头企业网站模板建站百度扫一扫网页版
  • elementui 做的网站行业关键词一览表
  • 网站后台内容编辑器怎么做外链
  • 佛山专业网站建设哪家好杭州seo排名费用
  • 卖高仿名牌手表网站网页设计主题参考
  • 网站开发的基本流程品牌宣传策略有哪些
  • 做网站必须要买服务器吗seo什么意思
  • dw做网站的搜索栏怎么做活动软文怎么写
  • 国外做的好的医疗网站重庆seo论坛
  • 百度谷歌seo优化seo排名怎么做
  • 服务器迁移对做网站的影响深圳疫情最新消息
  • 品牌建设全面升级百度seo推广价格
  • 免费独立域名申请北京百度seo关键词优化
  • 建站公司 万维科技网站友情链接出售
  • 衡阳公司做网站腾讯广告平台
  • 咸宁网站建设seo公司推荐