jquery - 如何强制 navbar-fixed-top 在一定高度后显示

标签 jquery html css twitter-bootstrap

我正在通过 php include 调用一个 template.php 页面。我在 index.php 页面和 html 页面中有一个 Bootstrap 导航栏。在执行 tepmlate.php 时,导航栏显示在 index.php 导航栏之上。

我想在 index.php 导航栏下方显示 template.php 导航栏,即我想在 index.php 下方显示整个 html 文件> 导航栏,html代码如下:

模板.php

<header id="navigation">
    <div class="navbar navbar-inverse navbar-fixed-top" role="banner">
        <div class="container">
            <div class="navbar-header" data-nitspagelabel="1">....

索引.php

<nav class="navbar navbar-default navbar-fixed-top editbar">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">

CSS 文件:

.editbar {
  height: 44px;
  position: fixed;
  width: 100%;
  min-width: 600px;
  box-shadow: 0 0 15px 0 rgba(22, 45, 61, 0.5);
  top: 0;
  left: 0;
  background-color: #fff;
  z-index: 100;
  line-height: 48px;
  margin-bottom: 1px;
  transition: 0.6s cubic-bezier(0.645, 0.045, 0.355, 1) top;
 }

是否有任何 jquery 函数可以解决此问题或任何 css 更改?

最佳答案

你只需要添加一个 top: 44px 到你的 template.php 导航栏。

Simple Bootply Example

.editbar {
  min-height: 44px; /* Override min-height of 50px */
  height: 44px;
}
.template-nav {
  top: 44px;
}

<div class="navbar navbar-inverse navbar-fixed-top template-nav" role="banner">
  <div class="container">
    <div class="navbar-header" data-nitspagelabel="1">template.php</div>
  </div>
</div>

<nav class="navbar navbar-default navbar-fixed-top editbar">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">index.php</div>
  </div>
</nav>

关于jquery - 如何强制 navbar-fixed-top 在一定高度后显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36918357/

相关文章:

CSS 特异性测试

javascript - 如何在选择下拉框时显示多个div元素?

html - Chrome 是如何从 HTML 渲染 PDF 的呢?

javascript - 随着用户不断输入,动态增加文本区域高度(没有滚动条)

javascript - 将 Jquery 对象传递给不适用于 IMG 的函数

html - 列表项的备用背景颜色

css - wordpress 侧边栏突出显示滚动上的事件链接并单击

jQuery 线索提示激活

php - 创建一个 unix 时间戳倒计时

javascript - 使用 Javascript 或 jQuery 检索 session 变量的简单快速的方法?