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

怎么做b2b网站推广杭州百度首页优化

怎么做b2b网站推广,杭州百度首页优化,网站开发有哪些,直播软件定制开发效果 实现方式 计时器:setTimeout或setInterval来计时。setInterval和 setTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。 问询:通过getCurrentLight将每个状态的持续时间设置…

效果

在这里插入图片描述

实现方式

  • 计时器:setTimeoutsetInterval来计时。setIntervalsetTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。
  • 问询:通过getCurrentLight将每个状态的持续时间设置为精确的值,并使用requestAnimationFrame来递归调用getCurrentLight函数,我们可以更准确地控制交通灯的状态。

源码

index.html

<!DOCTYPE html>
<html><head><title>交通灯</title><link type="text/css" rel="styleSheet" href="./index.css" /></head><body><div class="traffic-light"><div class="traffic-container"><div class="light green"></div><div class="light yellow"></div><div class="light red"></div></div><div class="time">90</div></div><script type="module">import {TrafficLight} from './TrafficLight.js';const time = document.querySelector('.time');const trafficDom = document.querySelector('.traffic-light');const light = new TrafficLight({red:3,yellow:2,green:5,initial:'red',});function raf(){requestAnimationFrame(()=>{raf();const current = light.getCurrentLight();time.textContent =current.remain;trafficDom.className = `traffic-light ${current.color}`;console.log(current.color,current.remain);})}raf();</script></body>
</html>

index.css

* {margin: 0;padding: 0;box-sizing: border-box;
}body{width: 100vw;height: 100vh;margin: 0;/* backgroud: #191c29 */background: #fff;
}.traffic-light{width: 200px;margin: 10px auto;-webkit-box-flex: inherit;text-align: center;
}.light{width: 20px;height: 20px;border-radius: 10px;display:inline-block;background-color: gray;margin: 10px auto;
}.red .red{background-color: red;
}.green .green{background-color: green;
}
.yellow .yellow{background-color: yellow;
}.time{font-family: 'DS-Digital';font-size: 40px;
}

TrafficLight.js

export class TrafficLight {constructor(options) {const {red = 60,green = 60,yellow = 3,initial = 'green',} = options || {};this._colors ={red:{seconds: red,next:'yellow',},green:{seconds: green,next:'yellow',},yellow:{seconds : yellow,},};this._switch(initial);}_switch(color){this._currentColor = color;this._seconds = this._colors[color].seconds;this._time = Date.now();}_next(){if(this._currentColor === 'red'){this._colors.yellow.next = 'green';}  else if(this._currentColor === 'green'){this._colors.yellow.next = 'red';} else{}this._switch(this._colors[this._currentColor].next);
}getCurrentLight(){const remain = Math.ceil(this._seconds -(Date.now() - this._time)/1000);if(remain<=0){this._next();return this.getCurrentLight();}return {color: this._currentColor,remain,};}}

字体 DS-Digital

下载字体 DS-Digital
注意:下载安装字体后需要重启浏览器才生效

http://www.mmbaike.com/news/89577.html

相关文章:

  • 长春网站建设南宁seo全网营销
  • 做的网站显示不了背景图片seo快照推广
  • 网站建设女装规划书推广平台app
  • 汽车网站建设策划书百度网盘下载安装
  • 建一个网站的技术解决方案网站收录有什么用
  • 做博彩的网站赚钱吗seo培训学校
  • 承德网站开发公司佛山营销型网站建设公司
  • 重庆响应式网站多少钱微信朋友圈广告推广
  • 湛江网站设计宁波企业seo外包
  • 网吧网站怎么做的市场推广的方法和规划
  • iis网站目录在哪推广方案策略怎么写
  • 网站建设文献翻译国家免费培训学校
  • 做海报在哪个网站可以找素材谷歌推广技巧
  • 天津建设部网站首页今日头条十大热点
  • 广东省做网站的公司品牌定位
  • wap网站服务器如何外贸推广
  • 运城做网站哪家公司好企业网站seo优化
  • 网站主机价格百度的网址
  • 宝山网站建设推广福州seo扣费
  • 企业网站建设制作公司关键词排名是由什么决定的
  • 网站做推广怎么收费seo自学网视频教程
  • 相城区建设网站百度引流推广怎么做
  • 浙江省建设厅证书查询长沙网络优化产品
  • 微信上浏览自己做的网站吗百度云网盘网页版
  • 重庆公安网站备案公司网站如何建设
  • 织梦dedecms大气微电影网站模板百度旅游官网
  • 做源码网站赚钱吗在线一键生成网页
  • 做旅游景区网站百度关键词点击工具
  • m 的手机网站怎么做深圳seo排名哪家好
  • wordpress建站vip全站教程国内十大搜索引擎排名