0

我想制作一个类似于这个网站 fcinq.com 的粘性标题但我对导航栏和菜单颜色样式有点困惑。我将容器放在标题中并将其分成两部分,但我无法像 fcinq.com 那样制作粘性标题

那么如何制作与 fcinq.com 相同的标题?网站链接:https ://www.fcinq.com/

<nav class="navbar navbar-inverse" role="navigation" style="">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="col-md-8" style="margin-bottom: 200px;">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <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="#about">Jhon Budy</a>
      </div>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="col-md-4" style="background: blue;/*! margin-bottom: 68px; */">
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav navbar-right">

          <li class="current" style="margin-top: 102px;margin-bottom: 60px;"><a href="#about">About</a>
            <a href="#work">Work</a>
            <a href="#contact">Contact</a></li>
        </ul>


      </div>
      <!-- /.navbar-collapse -->
    </div>
  </div>
  <!-- /.container-fluid -->
</nav>

4

3 回答 3

1

因为您似乎正在使用引导程序

https://getbootstrap.com/docs/3.3/components/#navbar-fixed-top

将您的导航代码更改为

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="">
于 2018-07-11T11:25:33.317 回答
0

您的问题不是很清楚,但据我所知,您可以直接包含以下 css 并根据您的需要修改内容。包括<header></header>在你的index.html.

header {
position: fixed;
z-index: 1111;
left: 0px;
right: 0px;
top: 28px;
height: 28px;
line-height: 28px;
text-align: center;
color: #fff;
background: #24397a;
box-sizing: border-box;
padding: 0 6px;
margin: 0px;
font-size: 20px;
text-transform: capitalize;
display: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

您还可以在标题中包含其他元素,tag例如锚标签、徽标等。

希望这会有所帮助!

于 2018-07-11T11:29:15.120 回答
0

这是我的粘性标题https://jsfiddle.net/Nethravathi/y7x9vost/1/的小提琴

$(function(){
    $('.navbar').affix({
      offset: {
        /* Affix the navbar after scroll below header */
        top: $("header").outerHeight(true)}
    });
});
@import url(https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css);

/* To mantain the navbar at the bottom*/
header {
  width: 100%;
  min-height:calc(100vh - 52px);
}


/* To mantain the navbar at the top once it is affixed */
.affix {
    top: 0;
    width: 100%;
  }

/* Padding for a smoth affix */
.affix + .container-fluid {
  padding-top: 72px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header class='container-fluid'>
  <h1>Title</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac neque et sem molestie scelerisque.<br/>In felis sem, pharetra ornare mi et, mattis rhoncus est.<br/>Fusce id nulla et enim molestie fermentum sed ullamcorper nibh. </p>
</header>

<nav class='navbar navbar-default'>
  <div class='container'>
    <div class='navbar-header'>
      <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 href='#' class='navbar-brand'> Title</a>
    </div>

    <div class='collapse navbar-collapse'>
      <ul class='nav navbar-nav navbar-right'>
        <li><a href=''>Link</a></li>
        <li><a href=''>Link</a></li>
        <li><a href=''>Link</a></li>
        <li><a href=''>Link</a></li>
      </ul>
    </div>
  </div>
</nav>

<div class='container-fluid'>
  <h1>Title</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac neque et sem molestie scelerisque.<br/>In felis sem, pharetra ornare mi et, mattis rhoncus est.<br/>Fusce id nulla et enim molestie fermentum sed ullamcorper nibh. </p>
  <h1>Title</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac neque et sem molestie scelerisque.<br/>In felis sem, pharetra ornare mi et, mattis rhoncus est.<br/>Fusce id nulla et enim molestie fermentum sed ullamcorper nibh. </p>
  <h1>Title</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac neque et sem molestie scelerisque.<br/>In felis sem, pharetra ornare mi et, mattis rhoncus est.<br/>Fusce id nulla et enim molestie fermentum sed ullamcorper nibh. </p>
  <h1>Title</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac neque et sem molestie scelerisque.<br/>In felis sem, pharetra ornare mi et, mattis rhoncus est.<br/>Fusce id nulla et enim molestie fermentum sed ullamcorper nibh. </p>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

于 2018-07-11T11:33:13.010 回答