在 CSS 专家的帮助下,如果用户向下滚动页面,我可以降低标题的高度。因此,与其使用小图片和相关标题,不如只留下标题,从而留出更多空间来查看网页。这是通过在用户向下滚动页面时自动将“滚动”类添加到页眉来完成的。
<header class="push" style="right: 0px; -webkit-transition: right 300ms ease; transition: right 300ms ease;"
成为:
class="push scrolled"
,当用户向上滚动页面时返回到 class="push"
,再次将小图像添加到页眉。
我的问题是针对特定页面的,我需要标题类永久位于 class="push scrolled"
。我该怎么做?
/* change on scroll */
header,
header * {
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
header.scrolled {
padding: 0px 0px 10px 0px;
}
header.scrolled #page-header-top .inner-wrap {
height: 0;
padding-top: 0;
padding-bottom: 0;
}
header.scrolled a#logo {
margin: 12px 0 5px;
}
header.scrolled ul#nav li a img {
height: 0;
margin: 0;
}
header.scrolled #mobile-btn {
margin: 10px 0 3px;
}
最佳答案
听起来你的类(class)被 JS 清空了,这就是为什么它没有举办类(class)。只要确保它在重新添加类时也包含滚动类即可。
关于javascript - 查看特定页面时将额外的 css 类应用于标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29367803/