超链接未出现在Twitter Boostrap网页上

时间:2017-11-04 18:19:48

标签: javascript jquery css twitter-bootstrap

我在Twitter Bootstrap的帮助下创建了一个简单的网页,最后的结果有几个问题:

  1. 虽然我已经为导航栏提供了一个" navbar-inverse"类,但它只显示为一个白色矩形,与网页内容的其余部分没什么区别。
  2. 我有三个带有空白href(href="")的链接,但它们不会出现。
  3. 以下是我获得的结果的链接:http://jsbin.com/poqofapiqa/edit?html,output

2 个答案:

答案 0 :(得分:2)

导航栏:

使用navbar-dark和bg-dark类代替:
<nav class="navbar navbar-dark bg-dark"><!-- Navbar content --></nav>

链接:

至少使用<a href="#">...</a>,而不是空白href属性。 具有空白属性的锚被解释为通常(非链接)元素

&#13;
&#13;
<!doctype html>
<html lang="en">
  <head>
    <title>Hello, world!</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
	
	<style>
	
		.box {
			border:1px solid grey;
			background-color:#d3d3d3;
		}
	
	</style>
	
  </head>
  <body>
  
	<div class="navbar navbar-dark bg-dark">
		
		<div class="container">
			
			<div class="navbar-header">
				
				<a href="#" class="navbar-brand">My Website</a>
				
			</div>
			
			<div class="collapse navbar-collapse">
				
				<ul class="nav navbar-nav">
					
					<li><a href="#">Page 1</a></li>
					
					<li><a href="#">Page 2</a></li>
					
					<li><a href="#">Page 3</a></li>
					
				</ul>
				
			</div>
			
		</div>
		
	</div>
	
    <h1>Hello, world!</h1>
	
	<div class="container">
		
		<div class="row">
		
			<div class="col-md-4 box">Content</div>
			
			<div class="col-md-4 box">Content</div>
			
			<div class="col-md-4 box">Content</div>
			
		</div>
		
	</div>	
	
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
  </body>
</html>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您正以错误的方式使用它。类nav-collapse用于显示移动菜单按钮。 nav-collapse中提供的内容不会显示在网页上。 您可以将此代码用于您的菜单。

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <ul class="nav navbar-nav">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>
</nav>
  

</body>
</html>