这是我现在正在使用的代码
<body style="height:1500px;" >
<nav class="navbar navbar-expand-lg navbar-fixed-top navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
这是我的代码,我想修复此导航顶部,我该怎么做............................... ................................................... ................................................... .........................................
答案 0 :(得分:1)
假设您使用的是最新的Bootstrap
,则将导航固定在顶部的类为.fixed-top
。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
fgvxgfc
<br /> dvcfvxvfx
<br /> dfdsfvsffvdxzd
<br /> fgvxgfc
<br /> dvcfvxvfx
<br /> dfdsfvsffvdxzd
<br /> dvcfvxvfx
<br /> dfdsfvsffvdxzd
<br /> fgvxgfc
<br /> dvcfvxvfx
<br /> dfdsfvsffvdxzd
<br /> dvcfvxvfx
<br /> dfdsfvsffvdxzd
<br /> fgvxgfc
<br /> dvcfvxvfx
<br /> dfdsfvsffvdxzd
答案 1 :(得分:0)
将CSS样式设置为 nav标签
postion:fixed;
width:100%
它将把您的导航仪固定在顶部
答案 2 :(得分:0)
您将需要position: fixed
例如:
div{
position: fixed;
height: 32px;
background-color: black;
width: 100%;
}
<div></div>
答案 3 :(得分:0)
我不知道您使用的是哪个引导程序版本,但是如果您使用的是最新版本的引导程序,则应在导航栏中将类“ navbar-fixed-top”替换为“ fixed-top”类,如果您将其替换,一切都会正常运行,我在您的代码中对其进行了尝试,并且一切正常,您可以在此处进行检查=> https://jsfiddle.net/aq9Laaew/90633/
sudo apt-get install wget
sudo apt-get install build-essential
sudo apt-get install libc6-dev
# find latest version of FreeTDS ftp://ftp.freetds.org/pub/freetds/stable/
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.92.tar.gz
tar -xzf freetds-1.00.92.tar.gz
cd freetds-1.00.92
./configure --prefix=/usr/local --with-tdsver=7.3
sudo make
sudo make install