引导菜单在单击移动时消失/&标题图像不会调整大小



所以我花了几个小时在其他人的帖子的帮助下自己解决这个问题,但没有运气。请让我首先解释我的问题。

我的网站www.discoverbugs.org有一个自举导航菜单。它在桌面上看起来不错,但是在移动设备上,单击时下拉菜单消失了。是什么原因导致它,我该如何解决?

第二个问题是标题图像。在移动设备上,它在整个手机的宽度上扩展。我在网站上有很多图像遇到了这个问题。我尝试添加最大宽度和最小宽度,这对我来说是不起作用的。有人可以帮我编辑吗?看起来很荒谬。

CSS:

@media screen and (max-width: 420px) { header {
padding: 65px 0 0px;  } }

index.php

    <header class="bg-primary text-white">
  <div class="container text-center">
    <img src="img/header-v6.jpg">
  </div>
</header>

header.php(导航菜单(

 <!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
  <div class="container">
    <a class="navbar-brand js-scroll-trigger" href="index.php">Discover Bugs</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="index.php">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="testimonials.php">Testimonials</a>
        </li>
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="collections.php">Collections</a>
        </li>
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="form.php">Costs & Booking</a>
        </li>
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="faq.php">FAQ</a>
        </li>
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="contact.php">Contact</a>
        </li>
      </ul>
    </div>
  </div>
</nav>

javascript编码我有:

<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>

原因很简单:bootstrap 3 JavaScript并非设计用于与Bootstrap 4一起使用。

换句话说,对于Bootstrap 4 CSS,您还需要Bootstrap 4 JavaScript(以及JQuery 3.2.1和Popper.js(。

要修复标题图像问题,将img-fluid类添加到图像中的类似:

<img class="img-fluid" src="img/header-v6.jpg">

这将使图像响应。

要修复第一个问题,请从以下模板中使用CSS和JavaScript文件(并按以下顺序加载(:

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  </head>
  <body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
    <div class="container">
        <a class="navbar-brand js-scroll-trigger" href="index.php">Discover Bugs</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="index.php">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="testimonials.php">Testimonials</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="collections.php">Collections</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="form.php">Costs & Booking</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="faq.php">FAQ</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="contact.php">Contact</a>
                </li>
            </ul>
        </div>
    </div>
</nav>
<div class="container mt-5 pt-5">
    <div class="row">
        <div class="col">
            <h1>Hello, world!</h1>
        </div>
    </div>
</div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

相关内容

  • 没有找到相关文章

最新更新