下拉按钮不能与bootstrap 4一起使用

时间:2018-01-12 10:46:21

标签: bootstrap-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>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中的图标......真的需要帮助。

1 个答案:

答案 0 :(得分:1)

Bootstrap 4 beta 3 中的下拉列表(和dropup等)所需的一项内容是包含popper.js

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

</body>

之前尝试包含以下内容

<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)并且您的代码运行正常。