Bootstrap как поставить панель навигации в выпадающем меню для короткого экрана? - PullRequest
0 голосов
/ 15 ноября 2018

Я пытаюсь настроить свою страницу указателя из комбинации jumbotron и fix nav bar примеров начальной загрузки.

Используя страницу исправления навигационной панели начальной загрузки, если уменьшить размер окна вместо списка навигационной панели, вы получите раскрывающееся меню с содержимым навигационной панели. В моем случае это не работает. Я не понимаю, чего там не хватает.

Тем не менее, если я скопирую строки между тегами <nav> и </nav> html на страницы примеров начальной загрузки, это сработает.

Это моя страница index.html:

<!DOCTYPE html>
<html lang="en-US">

  <head><meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="description" content="">
<meta name="author" content="Association M'Langues">

<link rel="icon" href="">

<title>Mon Association</title>

<!-- Bootstrap: Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Bootstrap: Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<link rel="stylesheet" href="/css/styles.css">
<!-- Begin Jekyll SEO tag v2.5.0 -->
<title>Mon Association</title>
<meta name="generator" content="Jekyll v3.7.4" />
<meta property="og:title" content="Association" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="L’association" />
<meta property="og:description" content="L’association" />
<link rel="canonical" href="http://localhost:4000/index2" />
<meta property="og:url" content="http://localhost:4000/index2" />
<meta property="og:site_name" content="Association" />
<script type="application/ld+json">
{"description":"L’association .","@type":"WebPage","url":"http://localhost:4000/index2","headline":"Association","@context":"http://schema.org"}</script>
<!-- End Jekyll SEO tag -->

  </head>

  <body>

    <!-- HEADER --><!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Association </a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav navbar-right"><li class="">
            <a href="/activites/">Activités</a>
        </li>
      <li class="">
            <a href="/actualites">Actualités de l&#39;association</a>
        </li>
      <li class="">
            <a href="/contact/">Contact</a>
        </li>
      <li class="">
            <a href="/about/">À Propos</a>
        </li>

      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>

<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
  <div class="container">
    <h1>Association </h1>
    <p>L'association a pour objectif la promotion .</p>
    <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
  </div>
</div>
<!-- MAIN CONTENT -->
    <div class="container">

      <p>Bonjour !</p>

<p>Bienvenu sur le site de l’Association </p>


      <!-- Example row of columns -->
      <div class="row">
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
        </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
       </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
          <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
        </div>
      </div>

      <!-- FOOTER  --><footer>

    <p class="copyright">Association </p>

    <p>Published with <a href="https://pages.github.com">GitHub Pages</a></p>
</footer>
</div>




    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
  </body>
</html>

1 Ответ

0 голосов
/ 16 ноября 2018

Сокращенный файл javascript Bootstrap :

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

должен быть включен после уменьшенного файла javascript JQuery :

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

Итак, ваш код должен быть таким:

<!DOCTYPE html>
<html lang="en-US">

  <head>

    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Association M'Langues">

    <link rel="icon" href="">    
    <title>Mon Association</title>

    <!-- Bootstrap: Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <link rel="stylesheet" href="/css/styles.css">
    <!-- Begin Jekyll SEO tag v2.5.0 -->
    <title>Mon Association</title>
    <meta name="generator" content="Jekyll v3.7.4" />
    <meta property="og:title" content="Association" />
    <meta property="og:locale" content="en_US" />
    <meta name="description" content="L’association" />
    <meta property="og:description" content="L’association" />
    <link rel="canonical" href="http://localhost:4000/index2" />
    <meta property="og:url" content="http://localhost:4000/index2" />
    <meta property="og:site_name" content="Association" />
    <script type="application/ld+json">
    {"description":"L’association .","@type":"WebPage","url":"http://localhost:4000/index2","headline":"Association","@context":"http://schema.org"}</script>
    <!-- End Jekyll SEO tag -->

  </head>

  <body>

    <!-- HEADER --><!-- Fixed navbar -->
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Association </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="">
              <a href="/activites/">Activités</a>
            </li>
            <li class="">
              <a href="/actualites">Actualités de l&#39;association</a>
            </li>
            <li class="">
              <a href="/contact/">Contact</a>
            </li>
            <li class="">
              <a href="/about/">À Propos</a>
            </li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <!-- Main jumbotron for a primary marketing message or call to action -->
    <div class="jumbotron">
      <div class="container">
        <h1>Association </h1>
        <p>L'association a pour objectif la promotion .</p>
        <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
      </div>
    </div>

    <!-- MAIN CONTENT -->
    <div class="container">
      <p>Bonjour !</p>    
      <p>Bienvenu sur le site de l’Association </p>

      <!-- Example row of columns -->
      <div class="row">
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
        </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
        </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
          <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
        </div>
      </div>

      <!-- FOOTER  -->
      <footer>    
        <p class="copyright">Association </p>    
        <p>Published with <a href="https://pages.github.com">GitHub Pages</a></p>
      </footer>
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>

    <!-- Bootstrap: Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  </body>
</html>
...