我目前正在本地服务器上使用免费版本的neve,我正在尝试使我的粘性标题基于滚动响应。
文本响应正确且变小,但徽标没有缩小。在javascript函数之外,我可以通过更改开发人员选项中的类来调整它的大小,但不响应滚动。
感谢您的帮助!
附加CSS
.header.shrink {
font-size: 13px;
position: fixed;
z-index:999999;
top: 0;
width: 100%;
transition: 0.2s;
}
.site-logo.shrink img{
max-height: 45px;
}
功能。php<script>
jQuery(document).ready(function($) {
$(window).scroll(function () {
if ($(window).scrollTop() > 10) {
$(\'header\').addClass(\'shrink\');
$(\'site-logo\').addClass(\'shrink\');
}
else{
$(\'header\').removeClass(\'shrink\');
$(\'site-logo\').removeClass(\'shrink\');
}
});
});
</script>
样式。css.site-logo {
align-items: center;
display: flex;
padding: 10px 0;
}
.site-logo amp-img img {
max-height: 60px;
}
.site-logo .brand {
display: flex;
flex-direction: column;
justify-content: center;
}
.site-logo .title-with-logo {
display: flex;
flex-direction: row;
align-items: center;
}
.site-logo .title-with-logo > img:first-child, .site-logo .title-with-logo > div:first-child {
margin-right: 10px;
}
.site-logo h1, .site-logo p {
font-family: inherit;
font-size: 1.25em;
margin-bottom: 0;
font-weight: 600;
}
.site-logo small {
width: 100%;
display: block;
}
.site-logo a {
color: #404248;
display: inline;
}
.site-logo a:hover {
color: #404248;
text-decoration: none;
opacity: .9;
}