0
以下代碼正常工作,我想實現的唯一目標是當您向下滾動或向上滾動背景時,例如從黑色變爲紅色。一些淡入淡出。附加更改從白色到黑色的平滑導航背景顏色
我該如何做到這一點?
身體:
<body data-spy="scroll" data-target=".navbar" data-offset="100">
風格:
body {
position: relative;
}
.affix {
top: 0;
width: 100%;
-webkit-transition: top 1s ease-in-out;
-webkit-transition-delay: 0.5s;
transition: top 1s ease-in-out;
transition-delay: 0.5s;
z-index: 9999 !important;
background: transparent!important;
}
.navbar {
margin-bottom: 0px;
border-radius: 0!important;
}
nav {
top:100px;
-webkit-transition: top 1s ease-in-out;
-webkit-transition-delay: 0.5s;
transition: top 1s ease-in-out;
transition-delay: 0.5s;
z-index: 9999 !important;
}
.affix ~ .container-fluid {
position: relative;
top: 100px;
}
HTML:
<nav class="navbar navbar-default" data-spy="affix" data-offset-top="0">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Name</a>
</div>
<div class="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown dropdown-large">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">XXXX<b class="caret"></b></a>
<ul class="dropdown-menu dropdown-menu-large row">
<li class="col-sm-2">
<ul>
<li class="dropdown-header navigatie"><a href="XXXX" title="XXXX">XXXX</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</nav>
對不起不工作,我只是想改變導航元素的背景顏色,上下滾動。 – Bas