Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jQuery滚动事件删除内联样式?_Jquery_Css - Fatal编程技术网

如何使用jQuery滚动事件删除内联样式?

如何使用jQuery滚动事件删除内联样式?,jquery,css,Jquery,Css,当我滚动到1400,然后从1400滚动到页面顶部时,我的chat1、2、3、4接收“空”内联样式,但仅持续1s。每次我滚动时,fadeIn会再次出现,延迟1秒 基本上,当滚动到1400时,我想一个接一个地显示4个img,而当滚动回到顶部时,我想让它们消失:) 这是我的CSS: #chat1{ position: relative; top: -1356px; z-index: 16; display: none; } 这是我的HTML: <div class="col-m

当我滚动到1400,然后从1400滚动到页面顶部时,我的chat1、2、3、4接收“空”内联样式,但仅持续1s。每次我滚动时,fadeIn会再次出现,延迟1秒

基本上,当滚动到1400时,我想一个接一个地显示4个img,而当滚动回到顶部时,我想让它们消失:)

这是我的CSS:

#chat1{
  position: relative;
  top: -1356px;
  z-index: 16;
  display: none;
}
这是我的HTML:

<div class="col-md-4">
  <div class="phone-container">
    <img src="images/Tuto/phone-frame.png" alt="Phone frame">
    <div class="phone-screen">

    <img src="images/Tuto/phone-background.png" alt="Phone background" id="phone-bg">
    <img src="images/Tuto/phone-footer-explore.png" alt="phone footer explore" id="phone-fot-exp">
      <div class="profile-screen">
        <img src="images/Tuto/Joanna.png" alt="Girl Profile" id="Girl-one-prof">
        <img src="images/Tuto/szymon.png" alt="Girl Profile" id="boy-one-prof">
      </div>
    <img src="images/Tuto/match.png" alt="match" class="match">
    <img src="images/Tuto/chat.png" alt="chat" id="chat">
    <img src="images/Tuto/chat1.png" alt="chat1" id="chat1">
    <img src="images/Tuto/chat2.png" alt="chat2" id="chat2">
    <img src="images/Tuto/chat3.png" alt="chat3" id="chat3">
    <img src="images/Tuto/chat4.png" alt="chat4" id="chat4">
  </div>
</div>


<>代码> 你考虑使用固定的定位元素来做这个工作吗?< /P> 此外,每次向上滚动时,您都会在每个
img
上触发一个动画,该动画需要花很长的时间来启动和完成,因此
.hide()
在试图隐藏受正在进行的动画影响的对象时处于超出其深度的位置;输入
.stop(true)
保存日期,并在匹配的元素上停止当前正在运行的动画

您甚至可以重构此代码,使其仅在通过1400px标记时触发动画一次,并且仅在向上通过时触发动画一次。
$('.phone screen')。子项('img')。每个(功能(i){
$(this.css('top',i*$(this.prev().height());
});
$(窗口)。滚动(函数(){
var scroll1=$(window.scrollTop();
var phoneScreen=$('.phone screen');
var chat1=phoneScreen.find('#chat1');
var chat2=phoneScreen.find('#chat2');
var chat3=phoneScreen.find('#chat3');
var chat4=phoneScreen.find('#chat4');
//===============================本部分=======================//
如果(滚动1>=1400){
chat1.delay(1000).fadeIn(200,函数(){
chat2.delay(200).fadeIn(200,函数(){
chat3.delay(200).fadeIn(200,函数(){
chat4.delay(200)、fadeIn(200);
});
});
});
}否则{
$('[id^=“chat”]')。停止(true)。隐藏();
}
});
[id^=“chat”]{
位置:固定;
排名:0;
z指数:16;
显示:无;
}
























/>






















/>





















r/>

















您的目标/问题是什么?当您滚动超过1400px时,您希望发生什么?当你滚动(scroll1>=1400)时,我想显示一些img,然后当我滚动到top scroll<1400px时,我想让它们消失。
chat1.hide()
??你能发布相关的html吗?你给我展示了一种滚动动画的新方法。我想我需要用你展示给我的东西重新制作一遍:)因为你可以在我的html中看到更多的元素。:)谢谢
<div class="col-md-4">
  <div class="phone-container">
    <img src="images/Tuto/phone-frame.png" alt="Phone frame">
    <div class="phone-screen">

    <img src="images/Tuto/phone-background.png" alt="Phone background" id="phone-bg">
    <img src="images/Tuto/phone-footer-explore.png" alt="phone footer explore" id="phone-fot-exp">
      <div class="profile-screen">
        <img src="images/Tuto/Joanna.png" alt="Girl Profile" id="Girl-one-prof">
        <img src="images/Tuto/szymon.png" alt="Girl Profile" id="boy-one-prof">
      </div>
    <img src="images/Tuto/match.png" alt="match" class="match">
    <img src="images/Tuto/chat.png" alt="chat" id="chat">
    <img src="images/Tuto/chat1.png" alt="chat1" id="chat1">
    <img src="images/Tuto/chat2.png" alt="chat2" id="chat2">
    <img src="images/Tuto/chat3.png" alt="chat3" id="chat3">
    <img src="images/Tuto/chat4.png" alt="chat4" id="chat4">
  </div>
</div>