【发布时间】:2020-06-11 09:18:33
【问题描述】:
我有带有大徽标的标题,我想在滚动超过 100 像素后使其变小,这工作正常但不流畅,我怎样才能使其流畅?
我的代码:-
$(function(){
$(window).scroll(function(){
if($(this).scrollTop() > 100){
$('header').addClass('fixed-header');
}
else{
$('header').removeClass('fixed-header');
}
});
});
header{ padding:0px; position: sticky; top:0px; left:0px; background: #FFF; z-index: 1000;}
header.fixed-header{box-shadow: 20px 4px 10px rgba(39, 59, 69, 0.2);}
header .logo img{width:200px;}
header.fixed-header .logo img{width:100px;}
.box-height{ height:500px;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
<div class="col-md-4">
<a href="#" class="logo"><img src="https://www.freepnglogos.com/uploads/google-logo-png-hd-11.png"></a>
</div>
</header>
<div class="box-height"></div>
【问题讨论】:
标签: javascript jquery css smooth-scrolling smoothing