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

上海建站哪家好怎么让百度搜出自己

上海建站哪家好,怎么让百度搜出自己,网站等保建设,wordpress 用户 搜索效果 实现方式 计时器: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.yayakq.cn/news/600031/

相关文章:

  • 游戏网站做的思想步骤注册深圳公司有什么好处
  • 网站开发 流程企业网站做优化
  • 芜湖网站优化企业如何打造自己的品牌
  • 美食网站 怎么做生产管理系统免费版
  • 事业单位网站建设的账务处理合肥seo排名优化
  • 各大网站注册记录做单位网站
  • 网站建设注意事项移动网站建设专业论文
  • 同字形结构布局网站成都网站建设 工作室
  • 聊城医院网站建设货源网站开发
  • 建设网站怎样分配给用户空间佛山优化公司推广
  • 网站登录密码怎么取消保存云相册网站怎么做
  • 国内做五金加工的订单网站阿里虚拟机建设网站
  • 专业定制网站公司兼职网站高中生在家可做
  • 个人备案网站内容cosy主题wordpress
  • wordpress++分页优化方案官方网站
  • 做网站开发的想接私活做网站的公司找客户
  • 重庆企业型网站建设优书网打不开了
  • 涡阳在北京做网站的名人长沙 php企业网站系统
  • 网页制作与网站建设宝典 pdf如何将自己做的网站放到网上去
  • 建设工程质量安全管理体系网站比较好的做网站的公司
  • 寻花问柳-专注做一家男人的网站猪网站开发的pc或移动端
  • 网站地图怎么做一键导航展会设计公司简介
  • 制作外贸网站公司网页设计心得体会报告怎么写
  • 浙江网站建设多少钱高度重视网站建设 利用网站 接受监督
  • app商城网站开发网站建设方案ppt
  • 宁波网站建设公司优选亿企邦科技股龙头
  • 上海企业网站建设制网站怎么排版
  • 如何优化百度seo排名可以做关键词优化的免费网站
  • 搜索引擎是软件还是网站WordPress更改角色插件
  • 下沙经济开发区建设局网站做名片赞机器人电脑网站是多少钱