导航栏无法点击

时间:2016-08-08 05:42:54

标签: html css

我正在学习如何写一个网站,但我有问题。我有一个带有下拉菜单的导航栏,我可以点击下拉菜单转到另一个页面但是没有下拉菜单的项目不能。例如我可以点击HTML CSS并转到该页面,但是如果我点击机器学习,我就无法做到。

这是我的导航栏代码和Css:



ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #B3E5FC;}

li {
float: left;}

li a, .dropbtn {
display: inline-block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;}

li a:hover, .dropdown:hover .dropbtn {
background-color: #6200EA;
color:white;}

li.dropdown {
display: inline-block;}

.dropdown-content {
display: none;
position: absolute;
background-color: #B3E5FC;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;}

.dropdown-content a:hover {background-color: #6200EA}
.dropdown:hover .dropdown-content {
   display: block;}
.ul {
     position: fixed;
     top: 20px0px;
     width: 100%;}
.active {
     background-color: #B3E5FC;
     color: Red;}

<ul>
		    <li><a class="active" herf="index.html">Home</a></li>			
			<li class="dropdown">
                <a href="#" class="dropbtn" >Code Language </a>
                <div class="dropdown-content">
                  <a href="HTML CSS.html">HTML CSS </a>
                  <a href="JavaScript.html">JavaScript</a>
                  <a href="Java.html">Java</a>
				  <a href="Android.html">Android</a>
				  <a href="Python.html">Python</a>
                </div>
		    </li> 
            <li class="nav">			
			<a herf="machine_learning.html">Machine Learning</a>
            <a herf="Internet Of Things.html">Internet Of Things</a>
            <a herf="Raspberry Pi.html">Raspberry Pi</a>
            <li class="dropdown">		
                <a href="#" class="dropbtn" >Others </a>
                <div class="dropdown-content">
                  <a href="Entertainment.html">Entertainment</a>
                  <a href="Cosmetic.html">Cosmetic</a>
                  <a href="Plants.html">Plants</a>
                </div>
		    </li>
			</li>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

看起来你拼错了“href”为“herf”

<a herf="machine_learning.html">Machine Learning</a>

应该是

<a href="machine_learning.html">Machine Learning</a>

答案 1 :(得分:0)

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

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
     <ul class="nav navbar-nav">
      <li class="active"><a href="index.html">Home</a></li>
      <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Code Language<span class="caret"></span></a>
        <ul class="dropdown-menu">
          <li><a href="HTML CSS.html">HTML CSS </a></li>
          <li><a href="JavaScript.html">JavaScript</a></li>
          <li><a href="Java.html">Java</a></li>
          <li><a href="Android.html">Android</a></li>
          <li><a href="Python.html">Python</a></li>
         </ul>
      </li>
      <li><a href="#">Page 2</a></li>
    </ul>
  </div>
</nav>
</body>
</html>

代替您的代码。您可以将此代码用于响应式导航栏。

更多参考..

http://www.w3schools.com/bootstrap/bootstrap_navbar.asp

http://v4-alpha.getbootstrap.com/components/navbar/