我希望列表下拉到按钮下方,但是我的下拉按钮在第一个div上并不是一直显示在它现在出现的第一个div上。
HTML
<div class="categories row" id = "secondDiv">
<div class = "col-md-4 header text-center">
<p id = "columnOne"> Find Your Favorite Celebrity </p>
<div class="dropdown-container">
<button class="btn btn-secondary dropdown-toggle btn-outline-danger btn-lg dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> JUST
<span class="caret"></span></button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Justin Bieber <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
<a class="dropdown-item" href="#">Taylor Swift <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
<a class="dropdown-item" href="#">Jay Z <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
<a class="dropdown-item" href="#">Beyonce <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
<a class="dropdown-item" href="#">Rihanna <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
<a class="dropdown-item" href="#">Ariana Grande <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
<a class="dropdown-item" href="#">Cherie Lum <input type="radio" id="ID" name="NAME" value="VALUE"><label for="ID"></label> </a>
</div>
</div>
</div>
CSS
.dropdown-container {
位置:相对; }.dropdown-menu {position:absolute;上:100%; /* 底部 按钮 / margin-left:-100px; / 左侧更多* /}
答案 0 :(得分:0)
这就是你要找的东西。
使用的CSS是
.dropdown-container {
position: relative;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0px;
}
.dropdown-menu a {
display: block;
}
.dropdown-container {
position: relative;
display: inline-block;
}