【发布时间】:2019-08-28 19:44:53
【问题描述】:
我有一个代码 sn-p,我在我的网站中使用它来在用户向下滚动网页时显示号召性用语 btn。但它不适用于我的一个网站。我已经研究过,找不到错误。这是link to the page I am using this code。为什么 JS 不给元素添加“atcbottomactive”类?
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 1100) {
$(".atcbottom").addClass("atcbottomactive");
} else {
$(".atcbottom").removeClass("atcbottomactive");
}
});
@media only screen and (min-width:1000px) {
.atcbottom {
display: none!important
}
.btnn {
margin-top: -60px!important
}
}
@media only screen and (max-width:999px) {
.atcbottomactivepopup {
margin-bottom: 60px
}
}
.atcbottom {
height: 60px;
width: 100vw;
position: fixed;
z-index: 102;
background: #fff;
bottom: -100px;
transition: 2s;
left: 0;
}
.atcbtn {
height: 40px;
background: #4cae4c;
width: 90vw;
margin-top: 10px;
margin-left: 5vw;
border: none;
color: #fff;
font-size: 20px;
}
.atcbottomactive {
bottom: 0
}
<div style="height:1000px; width: 100%; background: blue">
<div class='atcbottom'>
<div class="container">
<div class="row">
<a href="#ProductPrice-product-template">
<button type="button" class="atcbtn">Call to action</button>
</a>
</div>
</div>
</div>
</div>
【问题讨论】:
标签: javascript jquery html css scroll