<body data-spy="scroll" data-target="#d" data-offset="50" >
<nav class="navbar navbar-inverse navbar-fixed-top" id="d">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#links">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<tton>
<img src="img/logoMsg.png" class="img-responsive" width="100px" height="100px"/>
</div>
<div class="collapse navbar-collapse" id="links">
<ul class="nav navbar-nav">
<li><a href="#dl1">买票</a><>
<li><a href="#dl2">购车</a><>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle">支付方式</a>
<ul class="dropdown-menu">
<li><a href="">QQ支付</a><>
<li><a href="">微信支付</a><>
<li><a href="">支付宝支付</a><a class="badge">NEW VOID</a><>
</ul>
<>
</ul>
<div class="navbar-form navbar-left">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button class="btn btn-default">
<i class="fa fa-search"></i>
<tton>
</div>
</div>
</div>
</div>
<div class="navbar-form navbar-right">
<div class="form-group">
<button class="btn btn-primary btn-sm" data-target="#Logon" data-toggle="modal">登录<tton>
</div>
<div class="form-group">
<button class="btn btn-danger btn-sm">注册<tton>
</div>
</div>
</div>
</div>
</nav>
在想要响应的地方添加ID 就是li标签中的href
然后
<script>
$(()=>{
$('body').scrollspy({ target: '#d' });
})
</script>
<nav class="navbar navbar-inverse navbar-fixed-top" id="d">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#links">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<tton>
<img src="img/logoMsg.png" class="img-responsive" width="100px" height="100px"/>
</div>
<div class="collapse navbar-collapse" id="links">
<ul class="nav navbar-nav">
<li><a href="#dl1">买票</a><>
<li><a href="#dl2">购车</a><>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle">支付方式</a>
<ul class="dropdown-menu">
<li><a href="">QQ支付</a><>
<li><a href="">微信支付</a><>
<li><a href="">支付宝支付</a><a class="badge">NEW VOID</a><>
</ul>
<>
</ul>
<div class="navbar-form navbar-left">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button class="btn btn-default">
<i class="fa fa-search"></i>
<tton>
</div>
</div>
</div>
</div>
<div class="navbar-form navbar-right">
<div class="form-group">
<button class="btn btn-primary btn-sm" data-target="#Logon" data-toggle="modal">登录<tton>
</div>
<div class="form-group">
<button class="btn btn-danger btn-sm">注册<tton>
</div>
</div>
</div>
</div>
</nav>
在想要响应的地方添加ID 就是li标签中的href
然后
<script>
$(()=>{
$('body').scrollspy({ target: '#d' });
})
</script>