0
當我滾動它時,我已經設法改變圖像,但是它的定位完全錯誤並且不在導航欄中。我希望圖像在用戶向下滾動時改變顏色,但將圖像置於CSS中會使其錯位。有沒有一個好的方法來做到這一點?如何在bootstrap中滾動更改品牌形象?
CSS:
#fh5co-header .navbar-brand {
float: left;
display: block;
font-size: 30px;
font-weight: 700;
padding-left: 0;
color: #fff;
background: url(../images/loc2.png);
}
#fh5co-header.navbar-fixed-top {
position: fixed !important;
background: #fff;
-webkit-box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.1);
-ms-box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.1);
margin-top: 0px;
top: 0;
#fh5co-header.navbar-fixed-top .navbar-brand {
background: url(../images/loc.png);
color: #96281B;
HTML:
#fh5co-header.navbar-fixed-top .navbar-brand {
background: url(../images/loc.png);
color: #96281B;
<nav class="navbar navbar-default">
<div class="navbar-header">
<!-- Mobile Toggle Menu Button -->
<a href="#" class="js-fh5co-nav-toggle fh5co-nav-toggle" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"><i></i></a>
<a class="navbar-brand" href="index.html"></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#" data-nav-section="home"><span>Home</span></a></li>
<li><a href="#" data-nav-section="work"><span>Menus</span></a></li>
<li><a href="#" data-nav-section="testimonials"><span>Testimonials</span></a></li>
<li><a href="#" data-nav-section="services"><span>Services</span></a></li>
<li><a href="#" data-nav-section="about"><span>About</span></a></li>
<li><a href="#" data-nav-section="contact"><span>Contact</span></a></li>
<li><a href="#"><i class="icon-facebook"></i></a></li>
<li><a href="#"><i class="icon-twitter"></i></a></li>
</ul>
<ul class="social social-circle">
</ul>
</div>
</nav>
JS
var windowScroll = function() {
var lastScrollTop = 0;
$(window).scroll(function(event){
var header = $('#fh5co-header'),
scrlTop = $(this).scrollTop();
if (scrlTop > 500 && scrlTop <= 2000) {
header.addClass('navbar-fixed-top fh5co-animated slideInDown');
} else if (scrlTop <= 500) {
if (header.hasClass('navbar-fixed-top')) {
header.addClass('navbar-fixed-top fh5co-animated slideOutUp');
setTimeout(function(){
header.removeClass('navbar-fixed-top fh5co-animated slideInDown slideOutUp');
}, 100);
}
}
});
};