可列表选择菜单下拉框

huangapple go评论68阅读模式
英文:

Listable select menu dropdown

问题

你好,大家。我有一个选择菜单下拉框,但是有很多元素,我想让它可以滚动。怎么做呢?

例如:
示例

英文:

Hello everyone I have a select menu dropdown, but there are a lot of elements and I would like to make it scrollable. How can this be done?

For example:
Example

答案1

得分: 0

你可以设置一个固定的高度,类似于 height: 500px,然后设置 overflow-y: scroll。如果希望在菜单 div 内的内容不超过 div 的高度时隐藏滚动条,还可以使用 auto

.scrollable_dropdown {
  height: 500px;
  /* 也可以使用 auto */
  overflow-y: scroll;
}

有关可能选项的更多信息,请参考 https://stackoverflow.com/a/30379387/21677455

英文:

You can set a fixed height, something like height: 500px, then set overflow-y: scroll. You can also use auto if you would like the scrollbar to hide when the content inside of the menu div does not exceed the height of the div.

.scrollable_dropdown {
  height: 500px;
  /* This can also be auto */
  overflow-y: scroll;
}

Refer to https://stackoverflow.com/a/30379387/21677455 for more information about possible options.

huangapple
  • 本文由 发表于 2023年4月20日 04:20:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76058519.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定