javascript - 如何阻止导航栏在html中滚动时缩小
问题描述
我有一个已下载的导航栏,导航栏的代码如下:
<!--header start-->
<header id="masthead" class="header ttm-header-style-classic-overlay">
<!-- ttm-header-wrap -->
<div class="ttm-header-wrap">
<!-- ttm-stickable-header-w -->
<div id="ttm-stickable-header-w" class="ttm-stickable-header-w clearfix">
<div id="site-header-menu" class="site-header-menu">
<div class="site-header-menu-inner ttm-stickable-header">
<div class="container">
<!-- site-branding -->
<div class="site-branding">
<a class="home-link" href="index.html" title="Planwey" rel="home">
<img id="logo-img" class="img-center" width="260" src="images\TEIA Logo.png" alt="logo-img">
</a>
</div>
<!-- site-branding end -->
<!-- header-icins -->
<!--site-navigation -->
<div id="site-navigation" class="site-navigation">
<div class="ttm-menu-toggle">
</div>
<nav id="menu" class="menu">
<ul class="dropdown">
<li class="active"><a style="font-size:25px;" href="index.html">Telangana Event Industry Association</a>
</li>
                                           
<li>
</ul>
</nav>
</div>
<!-- site-navigation end-->
</div>
</div>
</div>
</div>
</div>
所以当我滚动时,导航栏缩小,onscroll JS函数。这使我的徽标被压缩,我在整个项目中搜索了该属性,但找不到它。这是我的网站链接供参考。
如何在滚动缩小时停止此操作并在滚动时使我的导航栏相同?
解决方案
通过查看您的源代码,您有一个使用滚动事件将类添加到标题的函数:
$(window).scroll(function(){
if ( matchMedia( 'only screen and (min-width: 1200px)' ).matches )
{
if ($(window).scrollTop() >= 1000 ) {
$('.ttm-stickable-header').addClass('fixed-header');
$('.ttm-stickable-header').addClass('visible-title');
}
else {
$('.ttm-stickable-header').removeClass('fixed-header');
$('ttm-stickable-header').removeClass('visible-title');
}
}
});
因此,如果您只是删除那段代码,它应该可以工作。
推荐阅读
- vb6 - 如何在VB6中动态设置文本框值
- python - 为什么内存密集型递归函数的执行被抑制而没有错误?
- javascript - Uncaught (in promise) TypeError: $.templates is not a function
- regex - PySpark 中是否有类似于 python 的 re.findall() 函数的函数?
- c - 关于 C 中宏的数据类型
- sql-server - 从 Powershell 插入 SQL Server 数据库时,为什么我的(大)字符串会被截断?
- sap - grant_privilege 表中的 SAP HANA 系统权限和应用程序权限
- ios - React-native run-ios 命令 - 找不到 iphone 模拟器
- asp.net-mvc - 资产作为目录连接/硬链接 - 更改跟踪无法正常工作
- python - 使用chdir后找不到任何文件或目录