当用户滚动div不能在JavaScript中工作时隐藏div

如何解决当用户滚动div不能在JavaScript中工作时隐藏div

我的网站上有一个使用HTML和CSS构建的部分,该部分包含一个滚动条,供用户向下滚动,完整代码如下:

var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
  var currentScrollPos = window.pageYOffset;
  if (prevScrollpos > currentScrollPos) {
    document.getElementById("zaif").style.top = "0";
  } else {
    document.getElementById("zaif").style.top = "-50px";
  }
  prevScrollpos = currentScrollPos;
}
.wrapsaipy {
  width: 95%;
  margin: 5px auto;
  max-width: 900px;
  font-weight: 100;
  font-family: 'Roboto',sans-serif;
}

.wrapsaipy h1 {
  font-weight: 100;
}

.termssaipy {
  color: #fff;
  height: 480px;
  cursor: move;
  padding: 10px;
  background: #43cea2;
  background: -webkit-linear-gradient(to right,#f2136e,#0cc3eb);
  background: -webkit-gradient(linear,left top,right top,from(#f2136e),to(#0cc3eb));
  background: -webkit-linear-gradient(left,#0cc3eb);
  background: -o-linear-gradient(left,#0cc3eb);
  background: linear-gradient(to right,#0cc3eb);
  overflow-y: scroll;
  border-radius: 3px;
  -webkit-box-shadow: 0 0 10px rgba(0,0.9);
  box-shadow: 0 0 10px rgba(0,0.9);
}

.termssaipy p {
  line-height: 25px;
}

.choicessaipy {
  margin-top: 40px;
}
<div class="kuttan" id="zaif">
  <div class="containerkuttan">
    <div class="chevron"></div>
    <div class="chevron"></div>
    <div class="chevron"></div>
    <span class="textkuttan"><b>Scroll down</b></span>
  </div>
</div>
<div class="wrapsaipy">
  <h1><b>TERMS AND CONDITIONS</b></h1>
  <div class="termssaipy">
    <p>The terms "We" / "Us" / "Our"/”Company” individually and collectively refer to FireZeal Internet Solutions Private Limited and the terms "Visitor” ”User” refer to the users.</p>
    <p>This page states the Terms and Conditions under which you (Visitor) may visit this website (“Website”). Please read this page carefully. If you do not accept the Terms and Conditions stated here,we would request you to exit this site. The business,any of its business divisions and / or its subsidiaries,associate companies or subsidiaries to subsidiaries or such other investment companies (in India or abroad) reserve their respective rights to revise these Terms and Conditions at any time
      by updating this posting. You should visit this page periodically to re-appraise yourself of the Terms and Conditions,because they are binding on all users of this Website.</p>
    <h3><b>USE OF CONTENT</b></h3>
    <p>All logos,brands,marks headings,labels,names,signatures,numerals,shapes or any combinations thereof,appearing in this site,except as otherwise noted,are properties either owned,or used under licence,by the business and / or its associate
      entities who feature on this Website. The use of these properties or any other content on this site,except as provided in these terms and conditions or in the site content,is strictly prohibited.</p>
    <p>You may not sell or modify the content of this Website or reproduce,display,publicly perform,distribute,or otherwise use the materials in any way for any public or commercial purpose without the respective organisation’s or entity’s written permission.</p>
    <h3><b>ACCEPTABLE WEBSITE USE</b></h3>
    <h5><b>(A) Security Rules</b></h5>
    <p>Visitors are prohibited from violating or attempting to violate the security of the Web site,including,without limitation,(1) accessing data not intended for such user or logging into a server or account which the user is not authorised to access,(2) attempting to probe,scan or test the vulnerability of a system or network or to breach security or authentication measures without proper authorisation,(3) attempting to interfere with service to any user,host or network,without
      limitation,via means of submitting a virus or "Trojan horse" to the Website,overloading,"flooding","mail bombing" or "crashing",or (4) sending unsolicited electronic mail,including promotions and/or advertising of products or services. Violations
      of system or network security may result in civil or criminal liability. The business and / or its associate entities will have the right to investigate occurrences that they suspect as involving such violations and will have the right to involve,and cooperate with,law enforcement authorities in prosecuting users who are involved in such violations.
    </p>
    <h5><b>(B) General Rules</b></h5>
    <p>Visitors may not use the Web Site in order to transmit,store or destroy material (a) that could constitute or encourage conduct that would be considered a criminal offence or violate any applicable law or regulation,(b) in a manner that
      will infringe the copyright,trademark,trade secret or other intellectual property rights of others or violate the privacy or publicity of other personal rights of others,or (c) that is libellous,defamatory,pornographic,profane,obscene,threatening,abusive or hateful.</p>
    <h3><b>INDEMNITY</b></h3>
    <p>The User unilaterally agree to indemnify and hold harmless,without objection,the Company,its officers,directors,employees and agents from and against any claims,actions and/or demands and/or liabilities and/or losses and/or damages whatsoever
      arising from or resulting from their use of or their breach of the terms .</p>
    <h3><b>LIABILITY</b></h3>
    <p>User agrees that neither company nor its group companies,officers or employee shall be liable for any direct or/and indirect or/and incidental or/and special or/and consequential or/and exemplary damages,resulting from the use or/and
      the inability to use the service or/and for cost of procurement of substitute goods or/and services or resulting from any goods or/and data or/and information or/and services purchased or/and obtained or/and messages received or/and transactions
      entered into through or/and from the service or/and resulting from unauthorized access to or/and alteration of user's transmissions or/and data or/and arising from any other matter relating to the service,including but not limited to,damages for
      loss of profits or/and use or/and data or other intangible,even if companyhas been advised of the possibility of such damages.</p>
    <p>User further agrees that company shall not be liable for any damages arising from interruption,suspension or termination of service,including but not limited to direct or/and indirect or/and incidental or/and special consequential or/and exemplary
      damages,whether such interruption or/and suspension or/and termination was justified or not,negligent or intentional,inadvertent or advertent. User agrees that companyshall not be responsible or liable to user,or anyone,for the statements or
      conduct of any third party of the service. In sum,in no event shall Company's total liability to the User for all damages or/and losses or/and causes of action exceed the amount paid by the User to company,if any,that is related to the cause
      of action.</p>
    <h3><b>DISCLAIMER OF CONSEQUENTIAL DAMAGES</b></h3>
    <p>In no event shall Company or any parties,organizations or entities associated with the corporate brand name us or otherwise,mentioned at this Website be liable for any damages whatsoever (including,without limitations,incidental and consequential
      damages,lost profits,or damage to computer hardware or loss of data information or business interruption) resulting from the use or inability to use the Website and the Website material,whether based on warranty,contract,tort,or any other
      legal theory,and whether or not,such organization or entities were advised of the possibility of such damages.</p>


  </div>



</div>

如您所见,我给了一个div说“向下滚动”,以便用户理解下面的内容。我希望在用户滚动条时隐藏div,如您所见,我已经为其提供了JavaScript,但它无法正常工作。谁能告诉我这里可能出什么问题了。

解决方法

var lastScrollTop = 50;
// chose at what distance to hide div

document.getElementById("frame").onscroll = function() {
//attach scroll event to your scroll-able div (added id="frame" to html)

  var st = window.pageYOffset || document.getElementById("frame").scrollTop;
//calculate distance

  if (st > lastScrollTop) {
    document.getElementById("zaif").style.display = "none";
    console.clear();
    console.log(st)
    console.log("scrooling div down")
  } else {
    document.getElementById("zaif").style.display = "block";
    console.clear();
    console.log(st)
    console.log("scrooled back to top")
  }
}
.wrapsaipy {
  width: 95%;
  margin: 5px auto;
  max-width: 900px;
  font-weight: 100;
  font-family: 'Roboto',sans-serif;
}

.wrapsaipy h1 {
  font-weight: 100;
}

.termssaipy {
  color: #fff;
  height: 480px;
  cursor: move;
  padding: 10px;
  background: #43cea2;
  background: -webkit-linear-gradient(to right,#f2136e,#0cc3eb);
  background: -webkit-gradient(linear,left top,right top,from(#f2136e),to(#0cc3eb));
  background: -webkit-linear-gradient(left,#0cc3eb);
  background: -o-linear-gradient(left,#0cc3eb);
  background: linear-gradient(to right,#0cc3eb);
  overflow-y: scroll;
  border-radius: 3px;
  -webkit-box-shadow: 0 0 10px rgba(0,0.9);
  box-shadow: 0 0 10px rgba(0,0.9);
}

.termssaipy p {
  line-height: 25px;
}

.choicessaipy {
  margin-top: 40px;
}
<div class="kuttan" id="zaif">
  <div class="containerkuttan">
    <div class="chevron"></div>
    <div class="chevron"></div>
    <div class="chevron"></div>
    <span class="textkuttan"><b>Scroll down</b></span>
  </div>
</div>
<div class="wrapsaipy">
  <h1><b>TERMS AND CONDITIONS</b></h1>
  <div class="termssaipy" id="frame">
    <p>The terms "We" / "Us" / "Our"/”Company” individually and collectively refer to FireZeal Internet Solutions Private Limited and the terms "Visitor” ”User” refer to the users.</p>
    <p>This page states the Terms and Conditions under which you (Visitor) may visit this website (“Website”). Please read this page carefully. If you do not accept the Terms and Conditions stated here,we would request you to exit this site. The business,any of its business divisions and / or its subsidiaries,associate companies or subsidiaries to subsidiaries or such other investment companies (in India or abroad) reserve their respective rights to revise these Terms and Conditions at any time
      by updating this posting. You should visit this page periodically to re-appraise yourself of the Terms and Conditions,because they are binding on all users of this Website.</p>
    <h3><b>USE OF CONTENT</b></h3>
    <p>All logos,brands,marks headings,labels,names,signatures,numerals,shapes or any combinations thereof,appearing in this site,except as otherwise noted,are properties either owned,or used under licence,by the business and / or its associate
      entities who feature on this Website. The use of these properties or any other content on this site,except as provided in these terms and conditions or in the site content,is strictly prohibited.</p>
    <p>You may not sell or modify the content of this Website or reproduce,display,publicly perform,distribute,or otherwise use the materials in any way for any public or commercial purpose without the respective organisation’s or entity’s written permission.</p>
    <h3><b>ACCEPTABLE WEBSITE USE</b></h3>
    <h5><b>(A) Security Rules</b></h5>
    <p>Visitors are prohibited from violating or attempting to violate the security of the Web site,including,without limitation,(1) accessing data not intended for such user or logging into a server or account which the user is not authorised to access,(2) attempting to probe,scan or test the vulnerability of a system or network or to breach security or authentication measures without proper authorisation,(3) attempting to interfere with service to any user,host or network,without
      limitation,via means of submitting a virus or "Trojan horse" to the Website,overloading,"flooding","mail bombing" or "crashing",or (4) sending unsolicited electronic mail,including promotions and/or advertising of products or services. Violations
      of system or network security may result in civil or criminal liability. The business and / or its associate entities will have the right to investigate occurrences that they suspect as involving such violations and will have the right to involve,and cooperate with,law enforcement authorities in prosecuting users who are involved in such violations.
    </p>
    <h5><b>(B) General Rules</b></h5>
    <p>Visitors may not use the Web Site in order to transmit,store or destroy material (a) that could constitute or encourage conduct that would be considered a criminal offence or violate any applicable law or regulation,(b) in a manner that
      will infringe the copyright,trademark,trade secret or other intellectual property rights of others or violate the privacy or publicity of other personal rights of others,or (c) that is libellous,defamatory,pornographic,profane,obscene,threatening,abusive or hateful.</p>
    <h3><b>INDEMNITY</b></h3>
    <p>The User unilaterally agree to indemnify and hold harmless,without objection,the Company,its officers,directors,employees and agents from and against any claims,actions and/or demands and/or liabilities and/or losses and/or damages whatsoever
      arising from or resulting from their use of or their breach of the terms .</p>
    <h3><b>LIABILITY</b></h3>
    <p>User agrees that neither company nor its group companies,officers or employee shall be liable for any direct or/and indirect or/and incidental or/and special or/and consequential or/and exemplary damages,resulting from the use or/and
      the inability to use the service or/and for cost of procurement of substitute goods or/and services or resulting from any goods or/and data or/and information or/and services purchased or/and obtained or/and messages received or/and transactions
      entered into through or/and from the service or/and resulting from unauthorized access to or/and alteration of user's transmissions or/and data or/and arising from any other matter relating to the service,including but not limited to,damages for
      loss of profits or/and use or/and data or other intangible,even if companyhas been advised of the possibility of such damages.</p>
    <p>User further agrees that company shall not be liable for any damages arising from interruption,suspension or termination of service,including but not limited to direct or/and indirect or/and incidental or/and special consequential or/and exemplary
      damages,whether such interruption or/and suspension or/and termination was justified or not,negligent or intentional,inadvertent or advertent. User agrees that companyshall not be responsible or liable to user,or anyone,for the statements or
      conduct of any third party of the service. In sum,in no event shall Company's total liability to the User for all damages or/and losses or/and causes of action exceed the amount paid by the User to company,if any,that is related to the cause
      of action.</p>
    <h3><b>DISCLAIMER OF CONSEQUENTIAL DAMAGES</b></h3>
    <p>In no event shall Company or any parties,organizations or entities associated with the corporate brand name us or otherwise,mentioned at this Website be liable for any damages whatsoever (including,without limitations,incidental and consequential
      damages,lost profits,or damage to computer hardware or loss of data information or business interruption) resulting from the use or inability to use the Website and the Website material,whether based on warranty,contract,tort,or any other
      legal theory,and whether or not,such organization or entities were advised of the possibility of such damages.</p>


  </div>



</div>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-