汉堡导航按钮不会固定在右侧最小宽度(768 像素)

Hamburger Nav Button doesnt stay fixed on the right at min width(768px)

我可以让它在移动屏幕尺寸中保持在右侧,但对于桌面,它位于底部或者根本不显示。我什至给它添加了一个边框,以了解它在页面中的位置,但我没有看到它,也没有设置任何 z-indexs。

请记住,我在媒体查询中将其设置为位置:固定,顶部:0,右侧:0,它仍然会在大屏幕上停留在右上角...

.header{
    height: 100vh;
display: grid;
grid-template-columns: 80%;
    border: 10px solid red;
    justify-content: center;
    align-items: center;
}

.header{
    background:linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url("../img/pizzaguy.jpg") center;
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-position: 50% 45%;
  }

  .banner{
      text-align: center;
      border: 10px solid green;
  }


.banner-title{
    color: var(--Cwhite);
    font-size: 5rem;
    animation: Fromleft;
    animation-duration: 4s;
    animation-fill-mode: forwards;
   border: solid 1px red;
}

@keyframes Fromleft{
    0%{
        transform: translateX(-100px)
        opacity: 0;
    }
    50%{
        transform: translateX(30px);
    }
    100%{
        transform: translateX(0);
        opacity: 1;
    }
}

.banner-icons{
    margin: 1rem auto;
    width: 50%;
    display: grid;
    grid-template-columns: repeat(4, 2rem);
    grid-column-gap: 0.5rem;
}

.banner_social-icon{
    border-radius: 50%;
    border: 0.1rem solid var(--darkpurple);
    padding: .25rem;
    transition: all 0.5s linear;
    background: var(--CRed);
    color: var(--Cwhite);
}

.banner_social-icon:hover{
    background: black;
    color: var(--Cwhite);
    animation: bounce .75s 1;
}

@-webkit-keyframes bounce {
    0% {
transform: scale(1,1) translate(0px, 0px);
}

30%{
transform: scale(1,0.8) translate(0px, 5px); 
}

75%{
transform: scale(1,1.1) translate(0px, -5px); 
}

100% {
transform: scale(1,1) translate(0px, 0px);
}
}

@media screen and (max-width:600px){
    .banner-title{
        font-size: 3rem;
    }

    /* navigation button */

.navBtn{
    position: fixed;
    top: 5%;
    right: 5%;
    font-size: 3.5rem;
    color: var(--Cwhite);
    cursor: pointer;
  animation-name: pulse;
  animation-duration: 2s;
  animation-iteration-count: infinite;
  border: 20px solid purple;

}

/* nav btn animation */
@keyframes pulse{
    0%{
      transform: scale(1)
    }
    50%{
  transform: scale(1.3)
    }
    100%{
  transform: scale(1)
    }
  }

  @media screen and (min-width:768px){
    .navBtn{       
        text-align: right;
        
    }
  <header class="header" id="header">
        
        <div class="banner">
            <h1 class="banner-title">Pen Pen Pizza</h1>

                <div class="banner-icons">
                    
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-facebook fa-fw"></i>
                  </a>
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-twitter fa-fw"></i>
                  </a>
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-google-plus fa-fw"></i>
                  </a>
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-instagram fa-fw"></i>
                  </a>
                </div>
        </div>
        <div class="navBtn">
            <i class="fas fa-bars"></i>
          </div>
    </header>

您的 CSS 文件中缺少很多括号和分号。

检查这个,我添加了遗漏的括号。

.header{
    height: 100vh;
display: grid;
grid-template-columns: 80%;
    border: 10px solid red;
    justify-content: center;
    align-items: center;
}

.header{
    background:linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url("../img/pizzaguy.jpg") center;
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-position: 50% 45%;
  }

  .banner{
      text-align: center;
      border: 10px solid green;
  }


.banner-title{
    color: var(--Cwhite);
    font-size: 5rem;
    animation: Fromleft;
    animation-duration: 4s;
    animation-fill-mode: forwards;
   border: solid 1px red;
}

@keyframes Fromleft {
    0% {
        transform: translateX(-100px);
        opacity: 0;
    }
    50%{
        transform: translateX(30px);
    }
    100%{
        transform: translateX(0);
        opacity: 1;
    }
}

.banner-icons{
    margin: 1rem auto;
    width: 50%;
    display: grid;
    grid-template-columns: repeat(4, 2rem);
    grid-column-gap: 0.5rem;
}

.banner_social-icon{
    border-radius: 50%;
    border: 0.1rem solid var(--darkpurple);
    padding: .25rem;
    transition: all 0.5s linear;
    background: var(--CRed);
    color: var(--Cwhite);
}

.banner_social-icon:hover{
    background: black;
    color: var(--Cwhite);
    animation: bounce .75s 1;
}

@-webkit-keyframes bounce {
    0% {
transform: scale(1,1) translate(0px, 0px);
}

30%{
transform: scale(1,0.8) translate(0px, 5px); 
}

75%{
transform: scale(1,1.1) translate(0px, -5px); 
}

100% {
transform: scale(1,1) translate(0px, 0px);
}
}

@media screen and (max-width:600px){
    .banner-title{
        font-size: 3rem;
    }
}
    /* navigation button */

.navBtn{
    position: fixed;
    top: 5%;
    right: 5%;
    font-size: 3.5rem;
    color: var(--Cwhite);
    cursor: pointer;
  animation-name: pulse;
  animation-duration: 2s;
  animation-iteration-count: infinite;
  border: 20px solid purple;

}

/* nav btn animation */
@keyframes pulse{
    0%{
      transform: scale(1)
    }
    50%{
  transform: scale(1.3)
    }
    100%{
  transform: scale(1)
    }
  }

@media screen and (min-width:768px){
    .navBtn{       
        text-align: right;        
    }
}
  <header class="header" id="header">
        
        <div class="banner">
            <h1 class="banner-title">Pen Pen Pizza</h1>

                <div class="banner-icons">
                    
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-facebook fa-fw"></i>
                  </a>
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-twitter fa-fw"></i>
                  </a>
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-google-plus fa-fw"></i>
                  </a>
                  <a href="#" class="banner_social-icon">
                    <i class="fab fa-instagram fa-fw"></i>
                  </a>
                </div>
        </div>
        <div class="navBtn">
            <i class="fas fa-bars"></i>
          </div>
    </header>