Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使导航栏菜单移动响应?_Html_Css - Fatal编程技术网

Html 如何使导航栏菜单移动响应?

Html 如何使导航栏菜单移动响应?,html,css,Html,Css,我有一些家庭作业问题,所以我需要为一个学校项目创建一个网站,我的菜单导航栏不能响应移动,我不知道如何修复它。有人能帮忙吗?我正在使用Bootstrap3,这是我的代码 $(文档)。准备好了吗({ $('.dropdown toggle').dropdown() }); 切换导航 创建移动导航菜单 步骤1)添加HTML: 范例 <!-- Load an icon library to show a hamburger menu (b

我有一些家庭作业问题,所以我需要为一个学校项目创建一个网站,我的菜单导航栏不能响应移动,我不知道如何修复它。有人能帮忙吗?我正在使用Bootstrap3,这是我的代码

$(文档)。准备好了吗({
$('.dropdown toggle').dropdown()
});

切换导航
创建移动导航菜单

  • 步骤1)添加HTML:
  • 范例

    <!-- Load an icon library to show a hamburger menu (bars) on small screens -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <!-- Top Navigation Menu -->
    <div class="topnav">
      <a href="#home" class="active">Logo</a>
      <!-- Navigation links (hidden by default) -->
      <div id="myLinks">
        <a href="#news">News</a>
        <a href="#contact">Contact</a>
        <a href="#about">About</a>
      </div>
      <!-- "Hamburger menu" / "Bar icon" to toggle the navigation links -->
      <a href="javascript:void(0);" class="icon" onclick="myFunction()">
        <i class="fa fa-bars"></i>
      </a>
    </div>
    
    /* Style the navigation menu */
    .topnav {
      overflow: hidden;
      background-color: #333;
      position: relative;
    }
    
    /* Hide the links inside the navigation menu (except for logo/home) */
    .topnav #myLinks {
      display: none;
    }
    
    /* Style navigation menu links */
    .topnav a {
      color: white;
      padding: 14px 16px;
      text-decoration: none;
      font-size: 17px;
      display: block;
    }
    
    /* Style the hamburger menu */
    .topnav a.icon {
      background: black;
      display: block;
      position: absolute;
      right: 0;
      top: 0;
    }
    
    /* Add a grey background color on mouse-over */
    .topnav a:hover {
      background-color: #ddd;
      color: black;
    }
    
    /* Style the active link (or home/logo) */
    .active {
      background-color: #4CAF50;
      color: white;
    }
    
    /* Toggle between showing and hiding the navigation menu links when the user clicks on the hamburger menu / bar icon */
    function myFunction() {
      var x = document.getElementById("myLinks");
      if (x.style.display === "block") {
        x.style.display = "none";
      } else {
        x.style.display = "block";
      }
    }
    
  • 步骤3)添加JavaScript:
  • 范例

    <!-- Load an icon library to show a hamburger menu (bars) on small screens -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <!-- Top Navigation Menu -->
    <div class="topnav">
      <a href="#home" class="active">Logo</a>
      <!-- Navigation links (hidden by default) -->
      <div id="myLinks">
        <a href="#news">News</a>
        <a href="#contact">Contact</a>
        <a href="#about">About</a>
      </div>
      <!-- "Hamburger menu" / "Bar icon" to toggle the navigation links -->
      <a href="javascript:void(0);" class="icon" onclick="myFunction()">
        <i class="fa fa-bars"></i>
      </a>
    </div>
    
    /* Style the navigation menu */
    .topnav {
      overflow: hidden;
      background-color: #333;
      position: relative;
    }
    
    /* Hide the links inside the navigation menu (except for logo/home) */
    .topnav #myLinks {
      display: none;
    }
    
    /* Style navigation menu links */
    .topnav a {
      color: white;
      padding: 14px 16px;
      text-decoration: none;
      font-size: 17px;
      display: block;
    }
    
    /* Style the hamburger menu */
    .topnav a.icon {
      background: black;
      display: block;
      position: absolute;
      right: 0;
      top: 0;
    }
    
    /* Add a grey background color on mouse-over */
    .topnav a:hover {
      background-color: #ddd;
      color: black;
    }
    
    /* Style the active link (or home/logo) */
    .active {
      background-color: #4CAF50;
      color: white;
    }
    
    /* Toggle between showing and hiding the navigation menu links when the user clicks on the hamburger menu / bar icon */
    function myFunction() {
      var x = document.getElementById("myLinks");
      if (x.style.display === "block") {
        x.style.display = "none";
      } else {
        x.style.display = "block";
      }
    }
    

    创建移动导航菜单

  • 步骤1)添加HTML:
  • 范例

    <!-- Load an icon library to show a hamburger menu (bars) on small screens -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <!-- Top Navigation Menu -->
    <div class="topnav">
      <a href="#home" class="active">Logo</a>
      <!-- Navigation links (hidden by default) -->
      <div id="myLinks">
        <a href="#news">News</a>
        <a href="#contact">Contact</a>
        <a href="#about">About</a>
      </div>
      <!-- "Hamburger menu" / "Bar icon" to toggle the navigation links -->
      <a href="javascript:void(0);" class="icon" onclick="myFunction()">
        <i class="fa fa-bars"></i>
      </a>
    </div>
    
    /* Style the navigation menu */
    .topnav {
      overflow: hidden;
      background-color: #333;
      position: relative;
    }
    
    /* Hide the links inside the navigation menu (except for logo/home) */
    .topnav #myLinks {
      display: none;
    }
    
    /* Style navigation menu links */
    .topnav a {
      color: white;
      padding: 14px 16px;
      text-decoration: none;
      font-size: 17px;
      display: block;
    }
    
    /* Style the hamburger menu */
    .topnav a.icon {
      background: black;
      display: block;
      position: absolute;
      right: 0;
      top: 0;
    }
    
    /* Add a grey background color on mouse-over */
    .topnav a:hover {
      background-color: #ddd;
      color: black;
    }
    
    /* Style the active link (or home/logo) */
    .active {
      background-color: #4CAF50;
      color: white;
    }
    
    /* Toggle between showing and hiding the navigation menu links when the user clicks on the hamburger menu / bar icon */
    function myFunction() {
      var x = document.getElementById("myLinks");
      if (x.style.display === "block") {
        x.style.display = "none";
      } else {
        x.style.display = "block";
      }
    }
    
  • 步骤3)添加JavaScript:
  • 范例

    <!-- Load an icon library to show a hamburger menu (bars) on small screens -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <!-- Top Navigation Menu -->
    <div class="topnav">
      <a href="#home" class="active">Logo</a>
      <!-- Navigation links (hidden by default) -->
      <div id="myLinks">
        <a href="#news">News</a>
        <a href="#contact">Contact</a>
        <a href="#about">About</a>
      </div>
      <!-- "Hamburger menu" / "Bar icon" to toggle the navigation links -->
      <a href="javascript:void(0);" class="icon" onclick="myFunction()">
        <i class="fa fa-bars"></i>
      </a>
    </div>
    
    /* Style the navigation menu */
    .topnav {
      overflow: hidden;
      background-color: #333;
      position: relative;
    }
    
    /* Hide the links inside the navigation menu (except for logo/home) */
    .topnav #myLinks {
      display: none;
    }
    
    /* Style navigation menu links */
    .topnav a {
      color: white;
      padding: 14px 16px;
      text-decoration: none;
      font-size: 17px;
      display: block;
    }
    
    /* Style the hamburger menu */
    .topnav a.icon {
      background: black;
      display: block;
      position: absolute;
      right: 0;
      top: 0;
    }
    
    /* Add a grey background color on mouse-over */
    .topnav a:hover {
      background-color: #ddd;
      color: black;
    }
    
    /* Style the active link (or home/logo) */
    .active {
      background-color: #4CAF50;
      color: white;
    }
    
    /* Toggle between showing and hiding the navigation menu links when the user clicks on the hamburger menu / bar icon */
    function myFunction() {
      var x = document.getElementById("myLinks");
      if (x.style.display === "block") {
        x.style.display = "none";
      } else {
        x.style.display = "block";
      }
    }
    

    您最好从修复HTML标记错误开始。您最好从修复HTML标记错误开始