我正在尝试创建一个下拉菜单,当内容不适合屏幕时,我可以在其中滚动。但是,这不起作用,因为当文本不在屏幕上时,没有滚动条。
我应该怎么做?
这是我的代码:
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>
答案 0 :(得分:0)
谢谢大家。我找到了解决方案。基本上,我需要给出下拉列表的大小。否则,CSS不会让我滚动。