【问题标题】:Dropdown button isn't working with bootstrap 4下拉按钮不适用于引导程序 4
【发布时间】:2018-01-12 19:00:21
【问题描述】:
'<!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>Christmas Event</title>`

<!-- Bootstrap -->
<link href="bootstrap-4.0.0-beta.2-dist/css/bootstrap.min.css" 
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="christmas.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]-->
</head>
 <body>
 <div class="dropdown">
 <button class="btn btn-secondary dropdown-toggle" type="button" 
 id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-
 expanded="false">
 Dropdown button
 </button>
 <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
 <a class="dropdown-item" href="#">Action</a>
 <a class="dropdown-item" href="#">Another action</a>
 <a class="dropdown-item" href="#">Something else here</a>
 </div>
 </div>



<div class="section1">
<div class="container">
<div class="row">
<div class="col-sm-7 offset-6">
<h1>Come down to Augustine House on 15th December! Our Christmas event will 
include:</h1>
            <h2>Lapland is coming to Canterbury with our very own reindeer 
</h2>
        <h2>Ice ice baby! Decorate gingerbread with delicious icing and 
treats</h2>
        <h2>Sing along with the Gospel Choir and their festive carols</h2>
    </div>
   </div>


</div>
</div>

<!-- 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="js/bootstrap.min.js"></script>
</body>
</html> ` 

我的问题是,无论我尝试使用什么代码创建下拉选项(最好是在屏幕缩小时弹出),按钮都不会打开选项。有什么我想念的吗?我已经尝试了所有可能的组合,包括使用 font-awesome 中的图标。真的需要帮助。

【问题讨论】:

  • Bootstrap 4 现在是 beta 3。您那里有一个过时的 css 文件。
  • 我刚刚更新了它.. 这是正确的代码吗?--> 还是不行

标签: bootstrap-4


【解决方案1】:

Bootstrap 4 beta 3 中的下拉菜单(和下拉菜单等)需要做的事情之一是包含 popper.js

此外,使用过时的 jQuery 和过时的 Bootstrap css 也是一个坏主意。

尝试在&lt;/body&gt; 之前添加以下内容:

<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-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>

我已经使用这些文件(以及正确版本的 Bootstrap css)尝试了您的代码,并且您的代码运行良好。

【讨论】:

  • 我不知道,非常感谢!现在一切正常
猜你喜欢
  • 2015-04-19
  • 1970-01-01
  • 2016-12-11
  • 1970-01-01
  • 1970-01-01
  • 2018-06-05
  • 2015-09-11
  • 2022-09-28
  • 1970-01-01
相关资源
最近更新 更多