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

网站建设飠金手指排名十一最新消息新闻

网站建设飠金手指排名十一,最新消息新闻,平台推广的方法有哪些,帮忙推广的平台系列文章目录 文章目录 系列文章目录一、楼层滚动效果图如下1. 下图是纯Css实现的楼层滚动2.通过Js优化后的楼层滚动如下图(🌹🌹) 二、楼层滚动(Css实现)1.滚动原理2.代码如下 三、楼层滚动(JsCss优化后的楼层滚动&…

系列文章目录

文章目录

  • 系列文章目录
  • 一、楼层滚动效果图如下
    • 1. 下图是纯Css实现的楼层滚动
    • 2.通过Js优化后的楼层滚动如下图(🌹🌹)
  • 二、楼层滚动(Css实现)
    • 1.滚动原理
    • 2.代码如下
  • 三、楼层滚动(Js+Css优化后的楼层滚动)
    • HTML、CSS代码如下
    • JS代码如下
  • 总结(收工)

一、楼层滚动效果图如下

1. 下图是纯Css实现的楼层滚动

在这里插入图片描述

2.通过Js优化后的楼层滚动如下图(🌹🌹)

在这里插入图片描述


二、楼层滚动(Css实现)

1.滚动原理

  1. 使用了一个 Css的属性值 scroll-behavior 。 对应的信息可以查找网上的资料。
  2. 使用了锚点功能。和对应的 标签上的 id属性

2.代码如下

<!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>Document</title><style>* {padding: 0;margin: 0;}main {width: auto;height: 100vh;padding: 0 10px;overflow-y: scroll;scroll-behavior: smooth;}body ul {position: fixed;top: 50px;right: 50px;background-color: aliceblue;}ul li {width: 100%;height: 35px;line-height: 35px;text-align: center;border-bottom: 1px solid black;list-style: none;}ul li:active{background-color: rgb(255, 170, 0);}a {text-decoration: none;}a:hover {color: brown;}</style>
</head><body><ul><li> <a href="#sectionOne"> sectionOne</a> </li><li> <a href="#sectionTwo"> sectionTwo</a> </li><li> <a href="#sectionThree"> sectionThree</a> </li><li> <a href="#sectionFour"> sectionFour</a> </li><li> <a href="#sectionFive"> sectionFive</a> </li><li> <a href="#sectionSix"> sectionSix</a> </li><li> <a href="#sectionSeven"> sectionSeven</a> </li><li> <a href="#sectionEight"> sectionEight</a> </li></ul><main><section id="sectionOne" style="height: 500px;background-color: rgb(81, 185, 245);margin-bottom: 30px;">sectionOne</section><section id="sectionTwo" style="height: 500px;background-color: rgb(172, 176, 180);margin-bottom: 30px;">sectionTwo</section><section id="sectionThree" style="height: 500px;background-color: rgb(87, 216, 201);margin-bottom: 30px;">sectionThree</section><section id="sectionFour" style="height: 500px;background-color: aliceblue;margin-bottom: 30px;">sectionFour</section><section id="sectionFive" style="height: 500px;background-color: rgb(180, 153, 74);margin-bottom: 30px;">sectionFive</section><section id="sectionSix" style="height: 500px;background-color: rgb(96, 99, 175);margin-bottom: 30px;">sectionSix</section><section id="sectionSeven" style="height: 500px;background-color: rgb(224, 70, 238);margin-bottom: 30px;">sectionSeven</section><section id="sectionEight" style="height: 500px;background-color: rgb(226, 141, 101);margin-bottom: 30px;">sectionEight</section></main></body><script></script></html>

三、楼层滚动(Js+Css优化后的楼层滚动)

HTML、CSS代码如下

<style>* {padding: 0;margin: 0;}main {width: auto;height: 100vh;padding: 0 10px;overflow-y: scroll;scroll-behavior: smooth;}body ul {position: fixed;top: 50px;right: 50px;background-color: aliceblue;}ul li {width: 100%;height: 35px;line-height: 35px;text-align: center;border-bottom: 1px solid black;list-style: none;}a {display: inline-block;width: 100%;height: 100%;text-decoration: none;}a:hover {color: brown;}</style>
<body><ul><li><a href="#sectionOne"> sectionOne</a></li><li><a href="#sectionTwo"> sectionTwo</a></li><li><a href="#sectionThree"> sectionThree</a></li><li><a href="#sectionFour"> sectionFour</a></li><li><a href="#sectionFive"> sectionFive</a></li><li><a href="#sectionSix"> sectionSix</a></li><li><a href="#sectionSeven"> sectionSeven</a></li><li><a href="#sectionEight"> sectionEight</a></li></ul><main><section id="sectionOne" style="height: 500px;background-color: rgb(81, 185, 245);margin-bottom: 30px;">sectionOne</section><section id="sectionTwo" style="height: 500px;background-color: rgb(172, 176, 180);margin-bottom: 30px;">sectionTwo</section><section id="sectionThree" style="height: 500px;background-color: rgb(87, 216, 201);margin-bottom: 30px;">sectionThree</section><section id="sectionFour" style="height: 500px; background-color: aliceblue; margin-bottom: 30px">sectionFour</section><section id="sectionFive" style="height: 500px;background-color: rgb(180, 153, 74);margin-bottom: 30px;">sectionFive</section><section id="sectionSix" style="height: 500px;background-color: rgb(96, 99, 175);margin-bottom: 30px;">sectionSix</section><section id="sectionSeven" style="height: 500px;background-color: rgb(224, 70, 238);margin-bottom: 30px;">sectionSeven</section><section id="sectionEight" style="height: 500px;background-color: rgb(226, 141, 101);margin-bottom: 30px;">sectionEight</section></main>
</body>

JS代码如下

<script>let arr = [];let obj = nullvar sectionTags = document.querySelectorAll("section");var main = document.querySelector("main");var ul = document.querySelector("ul");var aTags = document.querySelectorAll("a");function removeColor() {aTags.forEach((element) => {element.style.background = "none";});}function getheight() {sectionTags.forEach((element) => {arr.push(element.offsetTop);});}function scrollMoveColor(e) {let scrollTop = e.srcElement.scrollTop;for (let i = 0; i < arr.length; i++) {if (scrollTop <= arr[i]) {removeColor();aTags[i].style.background = "rgb(255, 170, 0)";break;}}}getheight();main.addEventListener("scroll", scrollMoveColor);ul.addEventListener("click", function (e) {if (obj) {clearTimeout(obj)main.removeEventListener("scroll", scrollMoveColor);removeColor();e.target.style.background = "rgb(255, 170, 0)";}obj = setTimeout(() => {main.addEventListener("scroll", scrollMoveColor);}, 1000);});
</script>

总结(收工)

由于这里,只对跳转功能尽进行了展示。后续还会将【滚动条滚动到对应的区域】对应的标题进行高粱的功能进行优化!! 💪💪

目前:超简单的楼层滚动效果已经✅

如果对代码有疑问(🤔️)的👨‍🎓(👩‍🎓),一定要记得联系作者!!!!!!

http://www.zhongyajixie.com/news/6433.html

相关文章:

  • 上海自适应网站建设百度建站平台官网
  • 美女手机网站源码企业qq怎么申请
  • 外贸公司做网站该去哪里找竞价推广遇到恶意点击怎么办
  • 广州高端网站制作公司哪家好南昌网站seo
  • 小程序制作方案书seo人才
  • 政府信息网站如何建设抖音seo教程
  • 购物网站开发 需求分析廊坊seo整站优化
  • 电大的网站界面ui设计训练怎么做河北百度seo软件
  • 手机网站用什么后台成品网站1688入口的功能介绍
  • 购物网站开发django百度官方平台
  • 做视频网站需要多少带宽什么是电商
  • 陕西高端品牌网站建设如何进行网站的宣传和推广
  • 做网站算软件行业吗超级外链发布
  • 公安网站 模板深圳百度快照优化
  • 郑州营销型网站宁波seo推荐优化
  • 邯郸学校网站建设费用软文媒体
  • 最近出现的病毒seo专员工作容易学吗
  • 网站可以微信支付是怎么做的淘宝关键词怎么做排名靠前
  • 网站开发费用摊销时间南昌seo数据监控
  • 做目录的网站武汉seo网络营销推广
  • 企业网站建设方案文档百度网站优化排名
  • 做h游戏视频网站小小课堂seo自学网
  • 网站群建设技术规范上海今天发生的重大新闻
  • 宣传产品网站2345网址导航怎么彻底删掉
  • 企业网站建设制作设计哪家最专业长沙网络营销外包哪家好
  • 长春哪家做网站便宜竞价推广是做什么的
  • 网站发的文章如何优化福州seo公司
  • 想要一个网站关键词生成器在线
  • 德清网站建设成品视频直播软件推荐哪个好一点
  • 丰润网站建设关于网络推广的方法