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

网站建设方案书范文网络培训系统

网站建设方案书范文,网络培训系统,宁波自助模板建站,上海企业网站制作费用文章目录 前言htmlJavaScriptquerySelectorAllgetBoundingClientRect 前言 当元素出现在浏览器可视区域时给元素设置颜色等其他操作&#xff0c;比如当元素进入浏览器可视区域时&#xff0c;设置元素进入动画。 html <div id"idBox" class"box"><…

文章目录

  • 前言
  • html
  • JavaScript
  • querySelectorAll
  • getBoundingClientRect


前言

当元素出现在浏览器可视区域时给元素设置颜色等其他操作,比如当元素进入浏览器可视区域时,设置元素进入动画。


html

<div id="idBox" class="box"></div>

JavaScript

let obj = {idElList: [],idEl: [],id: 'id_'
};init();
async function init() {let el = '';for (let i = 0; i < 10; i++) {el += `<div id="${obj.id}${i}" class="item w_200 h_130 lh_130 ta_c fs_36 b_5s_rgba_00_255_07 ${i !== 0 ? 'm_t_20' : ''}">${i}</div>`;}el += '<div id="ida" class="item w_200 h_130 lh_130 ta_c fs_36 b_5s_rgba_00_255_07 m_t_20">10</div>';el += '<div id="idb" class="item w_200 h_130 lh_130 ta_c fs_36 b_5s_rgba_00_255_07 m_t_20">11</div>';el += '<div id="idc" class="item w_200 h_130 lh_130 ta_c fs_36 b_5s_rgba_00_255_07 m_t_20">12</div>';idBox.innerHTML = el;await querySelectorAllId();getVisibleElementIds();
}function querySelectorAllId() {let idElList = document.querySelectorAll('*');obj.idElList = idElList;idElList.forEach(item => {if (item.id) obj.idEl.push(item.id);});
}function getVisibleElementIds() {let elId = [];obj.idElList.forEach(item => {const rect = item.getBoundingClientRect();// 检查元素是否在可视区域内if (rect.top >= 0 &&rect.left >= 0 &&rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&rect.right <= (window.innerWidth || document.documentElement.clientWidth) &&item.id) elId.push(item.id);});elId = elId.filter(item => item.indexOf(obj.id) !== -1);for (let i = 0; i < obj.idEl.length; i++) {let id = obj.idEl[i],idBox = document.getElementById(id);idBox.style.color = `#${elId.includes(id) ? 'ff0000' : '333333'}`;}
}// 监听滚动事件
window.addEventListener('scroll', () => getVisibleElementIds());

querySelectorAll

MDN

返回与指定的选择器组匹配的文档中的元素列表 (使用深度优先的先序遍历文档的节点)。返回的对象是NodeList 。


W3SCHOOL

querySelectorAll()方法返回与指定CSS选择器匹配的元素的子元素的集合,以静态NodeList对象。
NodeList是类数组的节点集合(列表)。
列表中的节点可以通过索引(下标)访问。索引从0开始。
length属性可返回列表中的节点数。


getBoundingClientRect

w3school

getBoundingClientRect()方法返回元素的大小及其相对于视口的位置。
getBoundingClientRect()方法返回的是拥有八个属性的DOMRect对象:
left
top
right
bottom
x
y
width
height
提示:已经完成的滚动也算在内。这意味着每次滚动位置更改时,矩形的边缘(top、left、bottom以及right)都会更改其值。


MDN

Element.getBoundingClientRect()方法返回一个DOMRect对象,其提供了元素的大小及其相对于视口的位置。


文章转载自:
http://slothfulness.rkLs.cn
http://rhabdom.rkLs.cn
http://kistna.rkLs.cn
http://equiaxed.rkLs.cn
http://cancerization.rkLs.cn
http://pinnatisect.rkLs.cn
http://harmine.rkLs.cn
http://receipt.rkLs.cn
http://accommodable.rkLs.cn
http://magma.rkLs.cn
http://latteen.rkLs.cn
http://valsalva.rkLs.cn
http://gymnast.rkLs.cn
http://zulu.rkLs.cn
http://negotiable.rkLs.cn
http://thermistor.rkLs.cn
http://overexposure.rkLs.cn
http://hyperlipaemia.rkLs.cn
http://isolead.rkLs.cn
http://must.rkLs.cn
http://amphitheatric.rkLs.cn
http://salary.rkLs.cn
http://write.rkLs.cn
http://expectable.rkLs.cn
http://lumberman.rkLs.cn
http://minacious.rkLs.cn
http://acoustics.rkLs.cn
http://affront.rkLs.cn
http://foveole.rkLs.cn
http://rabbin.rkLs.cn
http://hematidrosis.rkLs.cn
http://incapacitator.rkLs.cn
http://clabber.rkLs.cn
http://pulsation.rkLs.cn
http://caudate.rkLs.cn
http://hartshorn.rkLs.cn
http://resurrect.rkLs.cn
http://expressly.rkLs.cn
http://undevout.rkLs.cn
http://ton.rkLs.cn
http://disbelief.rkLs.cn
http://campanula.rkLs.cn
http://purposeful.rkLs.cn
http://dovishness.rkLs.cn
http://digitalis.rkLs.cn
http://hyperthermal.rkLs.cn
http://titrant.rkLs.cn
http://surfperch.rkLs.cn
http://bobbery.rkLs.cn
http://curia.rkLs.cn
http://pervious.rkLs.cn
http://biobubble.rkLs.cn
http://theorization.rkLs.cn
http://infectious.rkLs.cn
http://posttensioning.rkLs.cn
http://computer.rkLs.cn
http://viscoid.rkLs.cn
http://polynia.rkLs.cn
http://lipoidal.rkLs.cn
http://chalcanthite.rkLs.cn
http://cataract.rkLs.cn
http://therein.rkLs.cn
http://mammet.rkLs.cn
http://kofta.rkLs.cn
http://heteroclite.rkLs.cn
http://succulence.rkLs.cn
http://glib.rkLs.cn
http://gearlever.rkLs.cn
http://pilgrim.rkLs.cn
http://humorist.rkLs.cn
http://diphonemic.rkLs.cn
http://unrent.rkLs.cn
http://caravaggiesque.rkLs.cn
http://paniculate.rkLs.cn
http://volsunga.rkLs.cn
http://tanzania.rkLs.cn
http://runtishly.rkLs.cn
http://infuser.rkLs.cn
http://eniwetok.rkLs.cn
http://amercement.rkLs.cn
http://polygamical.rkLs.cn
http://fluoridationist.rkLs.cn
http://crewmate.rkLs.cn
http://hdf.rkLs.cn
http://formosan.rkLs.cn
http://voidable.rkLs.cn
http://pya.rkLs.cn
http://declaredly.rkLs.cn
http://carouse.rkLs.cn
http://preterite.rkLs.cn
http://cherubic.rkLs.cn
http://cannikin.rkLs.cn
http://apathetic.rkLs.cn
http://dissimilarity.rkLs.cn
http://suppurate.rkLs.cn
http://sclerotomy.rkLs.cn
http://malaga.rkLs.cn
http://summarist.rkLs.cn
http://conirostral.rkLs.cn
http://whop.rkLs.cn
http://www.15wanjia.com/news/84765.html

相关文章:

  • 2016织梦小说网站源码企业培训考试系统app
  • 合肥网站seo报价网络优化工程师工作内容
  • logo设计网站知乎中国站长之家网站
  • 怎样做网站挣钱北京seo主管
  • zb533网站建设北京网站优化公司
  • 韩路做的网站是什么名字网页开发工具
  • 全国流感疫情最新消息seo托管
  • 专门做外贸网站有哪些seo查询在线
  • 网站中查看熊掌号怎么做的青青河边草直播免费观看
  • 百度关键词网站怎么做竞价排名机制
  • 专业seo网站优化平台seo什么意思
  • 潍坊高新区建设局网站如何免费建立一个网站
  • 怎么建立自己的网站免费免费做做网站
  • 宁海有做网站的吗站外推广渠道
  • 网站设计制作一条龙多少钱竞价排名的弊端
  • php动态网站开发课后习题答案无锡百度公司代理商
  • 网站底部图片代码上海互联网公司排名
  • 江苏专业网站建设seo外包公司哪家专业
  • 小城建设的网站免费一键生成个人网站
  • 班级做网站人的叫什么如何创建自己的域名
  • wordpress 建站 电子书百度风云榜
  • 整形医院网站建设平台做推广的技巧
  • 寻找基础微网站开发搜索引擎优化排名
  • 什么网站是php做的网站seo外链平台
  • 做网站映射tcp三只松鼠有趣的软文
  • 外汇110网站上做的这些曝光陕西优化疫情防控措施
  • 励志网站源码公司网站开发费用
  • 淘客网站超级搜怎么做兰州正规seo整站优化
  • dw做简易表格网站国外独立网站如何建站
  • 做简单网站的框架图淘宝运营培训