巨无霸在移动网站上打破导航栏

时间:2019-07-04 22:23:32

标签: html css bootstrap-4

Bootstrap Jumbotrons离开了我网站上的容器,这意味着移动版本上的导航栏无法显示在屏幕上。在没有巨型飞轮的其他页面上,不会出现此问题。

我尝试使用Card代替,但是当我将其放置为文字以外的其他内容时会遇到一些问题

<div class="row">
    <div class="jumbotron col-lg-8 col-md-12"
        style='margin-left: 15px; margin-top: 15px; padding-top: 10px; padding-bottom: 10px; margin-bottom: 10px;'>
        <h1 class="display-3">
            <b>Welcome to SkyWars.fun</b>
        </h1>
        <p class="lead">We focus on updating regularly, and we listen close to
            our community suggestions.</p>
        <hr class="my-4">
        <p>We have a perk system, comparable with kits or abillities. Any
            player can enable 3 perks at once. These perks give small advantages
            for your gameplay. Choose wisely, and adapt with your perks! Happy
            SkyWars! And have fun!</p>
        <p class="lead">
            <a class="btn btn-primary btn-lg" href="../tips" role="button">Tips
                and tricks</a>
        </p>
    </div>
</div>

和导航栏

<nav class="navbar navbar-expand-lg navbar-dark bg-primary" role="navigation">
    <a class="navbar-brand" href="../">IP: SkyWars.fun</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse"
        data-target="#navbarColor01" aria-controls="navbarColor01"
        aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarColor01">
        <ul class="navbar-nav mr-auto">
            <li
                class="nav-item <?php if($_SERVER['REQUEST_URI'] === '/') echo 'active' ?>"><a
                class="nav-link" href="https://www.skywars.fun/" title="Go to the main page">Home </a></li>
            <li class="nav-item <?php if(isPage('/about/')) echo 'active' ?>"><a
                class="nav-link" href="https://www.skywars.fun/about" title="Information about SkyWars.fun">About</a></li>
            <li class="nav-item <?php if(isPage('/tips/')) echo 'active' ?>"><a
                class="nav-link" href="https://www.skywars.fun/tips" title="Tips and Tricks">Tips</a></li>
            <li class="nav-item <?php if(isPage('/donate/')) echo 'active' ?>"><a
                class="nav-link" href="https://www.skywars.fun/donate" title="Donate">Donate</a></li>
            <li class="nav-item <?php if(isPage('/search/')) echo 'active' ?>"><a
                class="nav-link" href="https://www.skywars.fun/search" title="Leaderboard">Leaderboard</a></li>
        </ul>
        <form class="form-inline my-2 my-lg-0" action="../search" title="Lookup player">
            <input class="form-control mr-sm-2" type="text" name="player"
                placeholder="Search player">
            <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
        </form>
    </div>
</nav>

问题图片

https://drive.google.com/file/d/0ByAYcnq6pPDmNlJsUUNBbkM1aFRITEQ5TUF4U0JxWXpOYVBV/view?usp=sharing https://drive.google.com/file/d/0ByAYcnq6pPDmcnVsbTNMbkI2MnlNdmZocmtXV0FWbXpmUTdN/view?usp=sharing

1 个答案:

答案 0 :(得分:1)

* {
   margin: 0;
   padding: 0;
}

.banner {
    background: #e9ecef;
}

@media only screen and (max-width: 767px) {
.display-3 {
    font-size: 2rem !important;
}
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>JS Bin</title>
    <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-primary" role="navigation">
      <a class="navbar-brand" href="../">IP: SkyWars.fun</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse"
        data-target="#navbarColor01" aria-controls="navbarColor01"
        aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarColor01">
        <ul class="navbar-nav mr-auto">
          <li
            class="nav-item <?php if($_SERVER['REQUEST_URI'] === '/') echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/" title="Go to the main page">Home </a></li>
          <li class="nav-item <?php if(isPage('/about/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/about" title="Information about SkyWars.fun">About</a></li>
          <li class="nav-item <?php if(isPage('/tips/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/tips" title="Tips and Tricks">Tips</a></li>
          <li class="nav-item <?php if(isPage('/donate/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/donate" title="Donate">Donate</a></li>
          <li class="nav-item <?php if(isPage('/search/')) echo 'active' ?>"><a class="nav-link" href="https://www.skywars.fun/search" title="Leaderboard">Leaderboard</a></li>
        </ul>
        <form class="form-inline my-2 my-lg-0" action="../search" title="Lookup player">
          <input class="form-control mr-sm-2" type="text" name="player"
            placeholder="Search player">
          <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
        </form>
      </div>
    </nav>
    <section class="banner">
      <div class="container-fluid">
          <div class="row">
            <div class="col-12">
              <div class="jumbotron">
                <h1 class="display-3">
                  <b>Welcome to SkyWars.fun</b>
                </h1>
                <p class="lead">We focus on updating regularly, and we listen close to
                  our community suggestions.
                </p>
                <hr class="my-4">
                <p>We have a perk system, comparable with kits or abillities. Any
                  player can enable 3 perks at once. These perks give small advantages
                  for your gameplay. Choose wisely, and adapt with your perks! Happy
                  SkyWars! And have fun!
                </p>
                <p class="lead">
                  <a class="btn btn-primary btn-lg" href="../tips" role="button">Tips
                  and tricks</a>
                </p>
              </div>
            </div>
        </div>
      </div>
    </section>
    <script
      src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  </body>
</html>

我减小了小型设备的字体大小,它已经从容器中移出了。在使用主类之前,还请使用 .container> .row> .col-lg-12 [仅作为示例] 。供参考,请通过https://getbootstrap.com/docs/4.1/layout/grid/此链接。希望能解决您的问题