我正在使用 Bootstrap Pill Navigation (Bootstrap 4)。代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="bootstrap-4.5.0-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="bootstrap-4.5.0-dist/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<ul class="nav nav-pills">
<li class="nav-item"><a id="homeMenu" class="nav-link active" data-toggle="pill" href="#home">HOME</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="pill" href="#about">ABOUT</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="pill" href="#contact">CONTACT</a></li>
</ul>
<div class="tab-content container-fluid">
<div id="home" class="tab-pane fade show active" style="background-color:yellow">
<h1>Home</h1>
</div>
<div id="about" class="tab-pane fade" style="background-color:red">
<h1>About</h1>
</div>
<div id="contact" class="tab-pane fade" style="background-color:orange">
<h1>Contact</h1>
</div>
</div>
</div>
</body>
</html>
此代码在 localhost 上完美运行。但是当它上线时,链接不会重定向到相应的 ID。相反,该域仅显示为www.xyz.com/#(id)(单击相应链接时)并停留在初始视图(即主页选项卡)上。我是新手,所以不确定我哪里出错了!请帮忙!