如何在下拉菜单中添加滚动条



我正在尝试创建一个下拉菜单,当内容不适合屏幕时,我可以在其中滚动。然而,这并没有像我希望的那样工作,因为当文本离开屏幕时,不会出现任何滚动条。

我该怎么做?

这是我的代码:

body {
overflow-y: hidden;
}
.dropbtn {
height: 28px;
width: 50px;
padding: 16px;
font-size: 16px;
border: none;
}
.Panel {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 300px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.Panel:hover .dropdown-content {
display: block;
overflow: auto;
}
.Panel:hover .dropbtn {
background-size: 28px 50px;
background-repeat: no-repeat;
height: 50px;
width: 28px;
margin-left: 30px;
}
<body>
<div class="Panel">
<button class="dropbtn"></button>
<div id="myDropdown" class="dropdown-content">
<br> <br>
<a href="../" target="_self"> Home</a> <be>
<a href="../" target="_self"> Other</a> <br>
<a href="../" target="_self"> Other</a> <br>
<a href="../" target="_self"> Other</a> <br>
<a href="../" target="_self"> Other</a> <br>
</div>
</div>
</body>

谢谢大家。我找到了解决办法。基本上,我需要给出下拉列表的大小。否则,CSS不会让我放卷轴。

最新更新