繁体   English   中英

Bootstrap导航栏无响应

[英]Bootstrap Nav-Bar not responsive

第一次使用Bootstrap设计网站并且菜单出现问题。 我已经研究了该网站在不同设备上的外观,只要达到800 x 600,顶部的菜单就不会堆叠在顶部。 我已附上3张图片,仅附上看起来正确的第一张图片。 我还在另一个帖子中看到的head标签中包含了视口初始比例= 1。

菜单看起来正常 菜单在小型移动设备上无法正确堆叠

请有人指出正确的方向来纠正代码吗?

<nav class="navbar navbar-expand-md">
    <div class="container-fluid">
    <a class="navbar-brand text-left" href="index.html">iStudy University <i class="fas fa-graduation-cap"></i></a>


        <div class="navbar-nav ml-auto">
        <a id="menu-nav" class="nav-item nav-link px-3" href="index.html"><i class="fas fa-home" ></i> Home</a>
        <a id="menu-nav" class="nav-item nav-link px-3" href="#"><i class="fas fa-info-circle"></i> About</a>
        <a id="menu-nav" class="nav-item nav-link px-3" href="contact.html"><i class="fas fa-envelope"></i> Contact Us</a>

        <form class="form-inline px-2" action="#">
            <button class="btn btn-dark" type="submit">Sign Up</button>
            <button class="btn btn-dark" type="submit"><i class="fas fa-sign-in-alt"></i>Login</button>
        </form>
        </div>
    </div>
</nav>


    #menu-nav{
color: white;
}

/*TO COME BACK TO - BACKGROUND IMAGE TO HOMEPAGE*/
.site-header {
  background: url(img/home-header.jpg) no-repeat center;
  background-size: cover;
        }

.site-header .layout-hero {
  min-height: 100vh;
}

.navbar, .btn-dark {
  font-family: 'Amatic SC', cursive;
  font-weight: 800;
  border-radius: 25px;
  color: white;
}

.navbar-brand {
  font-size: 2.5rem;
  font-family: 'Amatic SC', cursive;
  font-weight: 600;
  color: white;
}

/*This is for the i in the logo name */
.navbar-brand::first-letter {
  font-family: 'Charm', cursive;
  color: #f5f5f5;
  text-shadow: 1px 1px #45b39d;
}


/*This is to override the logo defult blue */
.navbar-brand:hover {
  color: white;
}

/*Just for the menu */
.navbar-nav {
  background-image: linear-gradient(to bottom right, #5dade2, #45b39d);;
  padding: 4px;
  border-radius: 25px;
  box-shadow: 1px 2px 1px slategrey;
}

.navbar-collapse .nav-link{
  display: inline-block;
  background :#45b39d;
}
/*for small  devices*/

@media(max-width: 767px){
  .navbar-brand {
    font-size: 2.1rem;
  }

  .navbar-dark .navbar-toggler {
    border-color: rgba(255,255,255,.5);
  }

}

如果您希望菜单中的所有项目都一个接一个显示,请将其添加到媒体查询中

 @media(max-width: 767px){
    // the code to add
    .form-inline{
       display:flex;
       flex-direction: column;
     }
   // end
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM