简体   繁体   English

添加溢出-y后,宽下拉菜单被剪裁:滚动到侧边栏

[英]Wide Drop-down menu gets clipped after adding overflow-y: scroll to Sidebar

I have a R Shiny application, but I believe my question requires a HTML/CSS (possibly jQuery?) solution in which I am not too familiar with.我有一个 R Shiny 应用程序,但我相信我的问题需要一个我不太熟悉的 HTML/CSS(可能是 jQuery?)解决方案。 I produced two simple Shiny apps which exemplifies the issue I am currently facing.我制作了两个简单的 Shiny 应用程序,它们体现了我目前面临的问题。

https://sometesting.shinyapps.io/test/ https://sometesting.shinyapps.io/test/

https://sometesting.shinyapps.io/test_-_copy/ https://sometesting.shinyapps.io/test_-_copy/

The first one does not contain the CSS property:第一个包含CSS属性:

.sidebar {
  height: 95vh;
  width: 300px;
  position: fixed;
  overflow-y: scroll;
  }

While the 2nd link does contain the above CSS property.虽然第二个链接确实包含上述​​ CSS 属性。 You can see in the 2nd link, the drop-down menu gets clipped.您可以在第二个链接中看到,下拉菜单被剪掉了。

I would like to avoid this clipping issue, and have the drop-down menu go over the sidebar and scrollbar.我想避免这个剪辑问题,并让下拉菜单越过侧边栏和滚动条。 I've researched for many hours and found a few jQuery solutions, but due to my unfamiliarity with jQuery plus how drastically different the R Shiny-generated HTML syntax is to me, I am not able to solve this.我已经研究了很多小时并找到了一些 jQuery 解决方案,但是由于我不熟悉 jQuery 以及 R Shiny 生成的 HTML 语法对我来说有多么大的不同,我无法解决这个问题。

Thanks!谢谢!

Edit编辑

Thanks to moose for helping me solve this!感谢驼鹿帮我解决了这个问题! Check out this thread: Rendering Shiny Selectize pull-down menu on top查看此线程: 顶部的渲染闪亮选择下拉菜单

Pretty much, I placed dropdownParent: "body" in my selectizeInput function as such:几乎,我将 dropdownParent: "body" 放在我的 selectizeInput 函数中,如下所示:

selectizeInput("s1", h4("Select State:"), 
    options = list(dropdownParent = 'body'),
    choices = state.name)

You may need to adjust the width and height of your selectize-dropdown.您可能需要调整选择下拉列表的宽度和高度。 Thanks moose!谢谢麋鹿!

The issue is with the selectize dropdown.问题在于选择下拉列表。 If you made the html list visible, the overflow works as expected, but I'm assuming you need something more powerful than the default select list.如果您使 html 列表可见,溢出会按预期工作,但我假设您需要比默认选择列表更强大的东西。

There's a similar issue solved here: https://github.com/selectize/selectize.js/issues/192这里解决了一个类似的问题: https : //github.com/selectize/selectize.js/issues/192

Even though it's overflow-x rather than y, the solution should be the same.即使它是溢出-x 而不是 y,解决方案也应该是一样的。 Failing that, you can try Semantic UI's dropdown (or better yet, Fomantic UI)如果失败,您可以尝试 Semantic UI 的下拉菜单(或者更好的是,Fomantic UI)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM