如何在scolling中隐藏自举头中固定顶部的图像

时间:2016-09-05 20:38:02

标签: html css twitter-bootstrap

我正在使用Laravel和bootstrap的项目Blog工作,我需要在滚动后隐藏菜单图像,但问题是如果我更改图像的位置,顶部菜单会损坏所有网站必须始终可见,但顶部图像不必。

以下是它现在的显示方式

enter image description here

滚动后应该怎么做

enter image description here

我尝试了很多不同的jquery方法,nono working

这是我的网站直播http://soygarota.com/blog/public

这是我的导航代码

<div class="navbar navbar-fixed-top navbar-inverse text-center sin-bordes OpenSansExtraBold" role="navigation" id="nav">
    <div class="masthead hidden-xs">
        <img src="{{ asset('images/layout/header.JPG') }}" class="img-responsive logo-header-img"/>
        <img src="{{ asset('images/layout/header1.png') }}" class="img-responsive img-header-desktop"/>
    </div>
    <div class="container-fluid text-center nav-height">

        <div class="navbar-header text-center">

            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".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="{{route('front.index')}}">
                <img src="{{ asset('images/layout/header-mobile.png') }}" alt="Carolina Silva" class="img-responsive hidden-sm hidden-md hidden-lg img-header-logo">
            </a>
        </div>

        <div class="collapse navbar-collapse text-center
">
            <ul class="nav navbar-nav text-center">
                <li><a href="{{ Route('front.index') }}" class="HeaderLink">HOME</a></li>
                <li><a href="{{route('front.search.category', 'INSPIRATION')}}" class="HeaderLink">INSPIRATION</a></li>
                <li><a href="{{route('front.search.category', 'LIFESTYLE')}}" class="HeaderLink">LIFESTYLE</a></li>
                <li><a href="{{route('front.search.category', 'FASHION')}}" class="HeaderLink">FASHION</a></li>
                <li><a href="{{ route('front.about') }}" class="HeaderLink">ABOUT</a></li>
                <li><a href="{{ route('front.contact') }}" class="HeaderLink">CONTACT</a></li>
            </ul>

            <div class="col-sm-3 col-md-3 pull-right">
                {!! Form::open(['route' => 'front.index', 'method' => 'GET', 'class' => 'navbar-form','role' => 'search']) !!}
                <div class="input-group">
                    <div class="input-group-btn">
                        <button class="btn btn-default" type="submit" id="SearchInput"><i class="glyphicon glyphicon-search" id="SearchIcon"></i></button>
                    </div>
                    <input type="text" class="form-control" placeholder="SEARCH" name="srch_term" id="srch_term">
                </div>
                {!! Form::close() !!}
            </div>


        </div><!--/.nav-collapse -->


    </div>
</div>

问题是如何在不破坏设计的情况下使滚动工作隐藏图像?

1 个答案:

答案 0 :(得分:1)

试试这个代码段:

<script>
    $(document).ready(function() {
        $(window).scroll(function() {
            if ($("body").height() <= ($(window).height() + $(window).scrollTop()) || $(window).scrollTop() <= 50) {
                $(".masthead").show();
            }else {
                $(".masthead").hide();
            }
        });
    });
</script>

将变量值设置为要隐藏的点。 我希望它有所帮助:)