W3School 的响应式菜单代码不显示菜单图标

Responsive menu code from W3School doesn't show menu icon

我正在尝试制作一个商业网站。我在那里添加了一些内容,现在我添加了一个响应式菜单代码。代码来自 W3Schools。对我来说,响应式菜单的移动版本不起作用。这里有一些图片可以让你更好地理解...

这是我的网站

当我在内置编辑器上尝试时,会发生这种情况

这是tryit编辑器

这是我的 HTML 代码...

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">


<style>
    .mySlides {display:none;}
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    text-align: center;
    font-size: 30px;
}

.topnav {
  overflow: hidden;
  background-color: #333;
}

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav a.active {
  background-color: #4CAF50;
  color: white;
}

.topnav .icon {
  display: none;
}

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child) {display: none;}
  .topnav a.icon {
    float: right;
    display: block;
  }
}

@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive .icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
    .topheadering {
    font-weight: bold;
    font-style: normal;
    font-family: antic-slab;
    font-size: 75px;
    text-align: center;
}
}
#Topics {
    text-decoration: underline;
    font-weight: bolder;
    font-size: 50px;
}
</style>
<link href="css/topicsHome.css" rel="stylesheet" type="text/css">
</head>
<body>

<div class="topnav" id="myTopnav">
  <a href="#home" class="active">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
  <a href="#about">About</a>
  <a href="javascript:void(0);" class="icon" onclick="myFunction()">
    <i class="fa fa-bars"></i>
  </a>
</div>

<div style="padding-left:16px">
  <h2>Responsive Topnav Example</h2>
  <p>Resize the browser window to see how it works.</p>
</div>
<div style="height: 100px"></div>

<img src="images/MacAppersLogo.png" style="align-items: center; width: 67vmax;" class="centerImage"/> 


        <h1 class="topheadering">Title</h1>
        <div class="d">

    &emsp;


        <p class="normal">  text</p>
                </div>
                </div>
            </div>
                        </div>
                </div>
            </div>
      </div>
        <style>
            * {box-sizing: border-box}
body {font-family: Verdana, sans-serif; margin:0}
.mySlides {display: none}
img {vertical-align: middle;}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: relative;
  margin: auto;
}

/* Next & previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -22px;
  color: white;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
  background-color: rgba(0,0,0,0.8);
}

/* Caption text */
.text {
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active, .dot:hover {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
  .prev, .next,.text {font-size: 11px}
}
            .container {
              height: 200px;
              position: relative;
              border: 3px solid #F0F4F7;
            }

            .center {
              margin: 0;
              position: absolute;
              top: 50%;
              left: 50%;
              -ms-transform: translate(-50%, -50%);
              transform: translate(-50%, -50%);
            }

.mySlides {display:none;}



            .centerImage {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 50%;
}

            </style>

            &emsp;      
            &emsp;      
            <h2><center id="Topics">Our Softwares</center></h2>




            <p class="normal">Text</p>



                <div>
                    <div>
                        <div>
            <img src="images/xcode-icon.png" alt="Xcode" class="centerImage" style="width:200px;height:200px;" title="Xcode"/>
                            &emsp;
                    </div>
                    </div>
                </div>
          </div>
        &emsp;

        <article>
    <h2 id="Topics">Why choose us</h2>



        <p class="normal">Text</p>




            </article>




<h2 id="Topics">Meet our team</h2>

<div class="w3-content w3-display-container">
  <img class="mySlides" src="images/Person1.PNG" style="width: 100%" >
  <img class="mySlides" src="img_lights.jpg" style="width:100%">
  <img class="mySlides" src="img_mountains.jpg" style="width:100%">
  <img class="mySlides" src="img_forest.jpg" style="width:100%">

  <button class="w3-button w3-black w3-display-left" onclick="plusDivs(-1)">&#10094;</button>
  <button class="w3-button w3-black w3-display-right" onclick="plusDivs(1)">&#10095;</button>
</div>
</body>
<script>
    var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("mySlides");
  if (n > x.length) {slideIndex = 1}
  if (n < 1) {slideIndex = x.length}
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";  
  }
  x[slideIndex-1].style.display = "block";  
}

function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}
</script>

</body>
</html>

有什么办法可以解决移动菜单问题吗?

要使图标正常工作 - 在 <head> 中添加:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">