Chiranthaka Sampath Ответов: 2

Подменю в верхней навигационной сборке с использованием bootstrap не сворачиваются


Привет Ребята,

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

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap with HTML</title>

    <!-- Bootstrap -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	
	  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	
  </head>
  <body>
 	  
	<!-- Navbar with Dropdown Menus -->
	<!-- Start Navbar Top -->
	<nav class="navbar navbar-default">
		<div class="container">
			<!-- Toggle buttons snippet -  This will define the toggle buttons of the navigation when the screen gets smaller -->
			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
			<span class="sr-only">Toggle navigation</span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			</button>
			<!-- End of Toggle button snippet -->
			
			<!-- The Site Name or Brand name snippet -->
			<a class="navbar-brand" href="www.youtube.com" target="_blank">The Bootstrap Site with HTML</a>
			<!-- End of brand name snippet -->
			
			<!-- The below defines the navigation links in the Navbar. From this point you can create the links for the navigation -->
			<div class="navbar-collapse collapse">
				<ul class="nav navbar-nav navbar-right">
					<li ><a href="#">Home</a></li>
					<li ><a href="#">Technologies</a></li>
					<li ><a href="#">Partners</a></li>
					<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="drop-down">Products </a>
						<ul class="dropdown-menu">
						<li><a href="#">SaaS</a></li>
						<li><a href="#">PaaS</a></li>
						<li><a href="#">Cloud</a></li>
						<li><a href="#">IofT</a></li>
						</ul>
					</li>
				</ul>
			</div>
			<!--End of the navigation links in the Navbar -->
			
		</div>
	</nav>
	<!-- End of Navbar Top -->
	
	
  </body>
</html>


Что я уже пробовал:

<!DOCTYPE html>
< html lang= "en">
< голова>
<meta charset= "utf-8">
<meta http-equiv=" X-UA-совместимый "контент=" IE=edge">
в <мета имя="область просмотра" содержимого="ширина=устройство-ширина, начально-масштаб=1"и GT;
<!-- Вышеперечисленные 3 мета-тега *должны * быть первыми в голове; любое другое содержание головы должно быть * после * этих тегов -->
в <название&ГТ;загрузочный с HTML&ЛТ;/название&ГТ;

<!-- Bootstrap -->
& lt;link rel= "таблица стилей" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity= "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3rydg4va+PmSTsz/K68vbdEjh4u "crossorigin= "anonymous">

<!-- jQuery (необходим для плагинов JavaScript Bootstrap) -->
&ЛТ;скрипт СРЦ="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&ГТ;&ЛТ;/скрипт>
<!-- Включить все скомпилированные Плагины (ниже) или включить отдельные файлы по мере необходимости -->
&ЛТ;скрипт СРЦ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&ГТ;&ЛТ;/скрипт>


<!-- HTML5 shim и Respond.js для IE8 поддержка элементов HTML5 и медиа-запросов -->
<!-- Предупреждение: Respond.js не работает, если вы просматриваете страницу через Файл: / / -->
<!--[if lt IE 9]>
&ЛТ;скрипт СРЦ="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"&ГТ;&ЛТ;/скрипт>
&ЛТ;скрипт СРЦ="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&ГТ;&ЛТ;/скрипт>
<![endif]-->

< / head>
& lt;тело>

<!-- Навигационная панель с выпадающими меню - >
<!-- Начало навигации сверху --&ГТ;


<!-- Toggle buttons snippet-это определит кнопки переключения навигации, когда экран станет меньше -->
&ЛТ;кнопка типа="кнопка" класс="навигации-переключаться" данные-переключение="свернуть" данные-цель=".навигации-развал"и GT;
Переключение навигации



& lt;/кнопка>
<!-- Конец фрагмента кнопки переключения -->

<!-- Название сайта или фрагмент фирменного наименования -->
Загрузочный сайт с HTML
<!-- Конец фрагмента фирменного наименования -->

<!-- Ниже перечислены навигационные ссылки в навигационной панели. С этого момента вы можете создавать ссылки для навигации -->

<!-- Конец навигационных ссылок в навигационной панели -->



<!-- Конец верхней части навигационной панели -->


< / body>
< / html>

2 Ответов

Рейтинг:
19

Chiranthaka Sampath

У меня есть решение, вот оно. Я использовал этот пост на Сайте StackOverflow

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap with HTML</title>

     <!-- Bootstrap -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	
	  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link href="custom/custom.css" rel="stylesheet" type="text\css" />
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
	
	<!-- Adding a web font -->
	<!--<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css />-->
	
  </head>
  <body>
  
	<!-- Navbar with Dropdown Menus -->
	<!-- Start Navbar Top -->
	<nav class="navbar navbar-default">
    <div class="container">
      <!-- Toggle buttons snippet -  This will define the toggle buttons of the navigation when the screen gets smaller -->
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <!-- End of Toggle button snippet -->

      <!-- The Site Name or Brand name snippet -->
      <a class="navbar-brand" href="www.youtube.com" target="_blank">The Bootstrap Site with HTML</a>
      <!-- End of brand name snippet -->

      <!-- The below defines the navigation links in the Navbar. From this point you can create the links for the navigation -->
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#">Home</a>
          </li>
          <li><a href="#">Technologies</a>
          </li>
          <li><a href="#">Partners</a>
          </li>
          <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Products </a>
            <ul class="dropdown-menu">
              <li><a href="#">SaaS</a>
              </li>
              <li><a href="#">PaaS</a>
              </li>
              <li><a href="#">Cloud</a>
              </li>
              <li><a href="#">IofT</a>
              </li>
            </ul>
          </li>
        </ul>
      </div>
      <!--End of the navigation links in the Navbar -->

    </div>
  </nav>
	<!-- End of Navbar Top -->
  
	<!--- -->
	<!-- Bootstrap container & container-fluid -->
	<!-- Bootstrap container example -->
	<div class="container bootcontainer">
    <h1>Hello, world! - Using Container</h1>
	</div>
	
	<!-- Bootstrap container-fluid example -->
	<div class="container-fluid bootcontainerfluid">
	<h1>Hello, world! - Using Container Fluid</h1>
	</div>
	<!-- End of  Bootstrap container and container-fluid-->
	<!--- -->
	
	<!--- -->
	<!-- Bootstrap columns and rows -->
	<!-- Bootstrap columns example -->
	<div class="container">
	<div class="row">
	<div class="col-md-3">
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco 
	laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
	</div>
	<div class="col-md-6">
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco 
	laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
	</div>
	<div class="col-md-3">
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco 
	laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
	</div>
	</div>
	</div>
	<!-- End of Bootstrap columns & rows -->
	<!--- -->

  </body>
</html></link>


Рейтинг:
0

Chiranthaka Sampath

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap with HTML</title>

     <!-- Bootstrap -->
	 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	
	 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
     
	 <!-- Include all compiled plugins (below), or include individual files as needed -->
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	
	<!-- Font Awesome inclusion for the icons on the pages -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" type="text\css" />
	

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link href="custom/custom.css" rel="stylesheet" type="text\css" />
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
	
	<!-- Adding a web font -->
	<!--<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css />-->
	
  </head>
  <body>
  
	<!-- Navbar with Dropdown Menus -->
	<!-- Start Navbar Top -->
	<nav class="navbar navbar-default">
    <div class="container">
      <!-- Toggle buttons snippet -  This will define the toggle buttons of the navigation when the screen gets smaller -->
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <!-- End of Toggle button snippet -->

      <!-- The Site Name or Brand name snippet -->
      <a class="navbar-brand" href="www.youtube.com" target="_blank">The Bootstrap Site with HTML</a>
      <!-- End of brand name snippet -->

      <!-- The below defines the navigation links in the Navbar. From this point you can create the links for the navigation -->
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#">Home</a>
          </li>
          <li><a href="#">Technologies</a> 
          </li>
          <li><a href="#">Partners</a>
          </li>
          <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Products </a>
            <ul class="dropdown-menu">
              <li><a href="#">SaaS</a>
              </li>
              <li><a href="#">PaaS</a>
              </li>
              <li><a href="#">Cloud</a>
              </li>
              <li><a href="#">IofT</a>
              </li>
            </ul>
          </li>
        </ul>
      </div>
      <!--End of the navigation links in the Navbar -->

    </div>
  </nav>
	<!-- End of Navbar Top -->
	<!--- -->
	
	<!--- -->
	<!-- Bootstrap Page Header -->
	<div class="page-header">
		<h3>This is a page header</h3>
	</div>
	<!-- End of Bootstrap Page Header -->
	<!--- -->
	
	<!--- -->
	<!-- Bootstrap Jumbotron example -->
		<div class="container">
			<div class="jumbotron text-center">
		 	<h1>This is a Jumbotron in Bootstrap! </h1>
			<p>
				<button type="button" class="btn btn-primary">Primary</button>
				<button type="button" class="btn btn-success">Success</button>
			</p>
			</div>
	</div>
		<!-- End of Jumbotron -->
	<!--- -->
	
	<!--- -->
	<!-- Bootstrap button example -->
		<div class="container">
			<h4>Bootstrap Buttons</h4>
			
				<!-- The Large size buttons -->
				<p>
						<button type="button" class="btn btn-default btn-lg">Default</button>
						<button type="button" class="btn btn-primary btn-lg">Primary</button>
						<button type="button" class="btn btn-success btn-lg">Success</button>
						<button type="button" class="btn btn-info btn-lg">Info</button>
						<button type="button" class="btn btn-warning btn-lg">Warning</button>
						<button type="button" class="btn btn-danger btn-lg">Danger</button>
						<button type="button" class="btn btn-link btn-lg">Link</button>
				</p>
				
				<!-- The default size buttons -->
				<p>
						<button type="button" class="btn btn-default">Default</button>
						<button type="button" class="btn btn-primary">Primary</button>
						<button type="button" class="btn btn-success">Success</button>
						<button type="button" class="btn btn-info">Info</button>
						<button type="button" class="btn btn-warning">Warning</button>
						<button type="button" class="btn btn-danger">Danger</button>
						<button type="button" class="btn btn-link">Link</button>
				</p>
				
				<!-- The small size buttons -->
				<p>
						<button type="button" class="btn btn-default btn-sm">Default</button>
						<button type="button" class="btn btn-primary btn-sm">Primary</button>
						<button type="button" class="btn btn-success btn-sm">Success</button>
						<button type="button" class="btn btn-info btn-sm">Info</button>
						<button type="button" class="btn btn-warning btn-sm">Warning</button>
						<button type="button" class="btn btn-danger btn-sm">Danger</button>
						<button type="button" class="btn btn-link btn-sm">Link</button>
				</p>
				
				<!-- The small size buttons -->
				<p>
						<button type="button" class="btn btn-default btn-xs">Default</button>
						<button type="button" class="btn btn-primary btn-xs">Primary</button>
						<button type="button" class="btn btn-success btn-xs">Success</button>
						<button type="button" class="btn btn-info btn-xs">Info</button>
						<button type="button" class="btn btn-warning btn-xs">Warning</button>
						<button type="button" class="btn btn-danger btn-xs">Danger</button>
						<button type="button" class="btn btn-link btn-xs">Link</button>
				</p>
				
				
				
		</div>
	<!-- End of Bootstrap button example -->	
	<!--- -->
  
	<!--- -->
	<!-- Bootstrap container & container-fluid -->
	<!-- Bootstrap container example -->
	<div class="container bootcontainer">
    <h1>Hello, world! - Using Container</h1>
	</div>
	
	<!-- Bootstrap container-fluid example -->
	<div class="container-fluid bootcontainerfluid">
	<h1>Hello, world! - Using Container Fluid</h1>
	</div>
	<!-- End of  Bootstrap container and container-fluid-->
	<!--- -->
			<br />
	<!--- -->
	<!-- Bootstrap columns and rows -->
	<!-- Bootstrap columns example -->
	<div class="container">
	<div class="row">
	<div class="col-sm-4">
	<a href="#" class="thumbnail">
		<img src="images/CSharp_Logo.png" alt="CSharp Logo" />
	</a>
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco 
	laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
	</div>
	<div class="col-sm-4">
	<a href="#" class="thumbnail">
		<img src="images/HTML5_Logo.png" alt="HTML5 Logo" />
	</a>
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco 
	laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
	</div>
	<div class="col-sm-4">
	<a href="#" class="thumbnail">
		<img src="images/Python_Logo.png" alt="Python Logo" />
	</a>
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud


Richard Deeming

Если вы хотите обновить существующее решение, Нажмите зеленую ссылку "улучшить решение" в правом нижнем углу решения.

Не публикуйте свое обновление как новое решение.