大佬教程收集整理的这篇文章主要介绍了css – 设置Bootstrap导航栏的透明度滚动,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
直到现在,我使用引导提供的默认代码创建了一个透明导航栏.我唯一需要做的是设置它执行:BACkground-color:#color当访问者滚动下来.
当我在页面的顶部,导航栏是透明的,但当我向下滚动它变得不透明.
jQuery的:
/** * Listen to scroll to change header opacity class */ function checkScroll(){ var startY = $('.navbar').height() * 2; //The point where the navbar changes in px if($(window).scrollTop() > startY){ $('.navbar').addClass("scrolled"); }else{ $('.navbar').removeClass("scrolled"); } } if($('.navbar').length > 0){ $(window).on("scroll load resize",function(){ checkScroll(); }); }
您也可以使用ScrollSpy来执行此操作.
和你的CSS(示例):
//Add the below transitions to allow a smooth color change SIMILAR TO lyft .navbar { -webkit-transition: all 0.6s ease-out; -moz-transition: all 0.6s ease-out; -o-transition: all 0.6s ease-out; -ms-transition: all 0.6s ease-out; transition: all 0.6s ease-out; } .navbar.scrolled { BACkground: rgb(68,68,68); //IE BACkground: rgba(0,0.78); //NON-IE }
以上是大佬教程为你收集整理的css – 设置Bootstrap导航栏的透明度滚动全部内容,希望文章能够帮你解决css – 设置Bootstrap导航栏的透明度滚动所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。