css - Shiny 的 R - 允许滚动条在 div 之上而不是在 div 之内

标签 css r shiny

我有一个选项列表,用于多个输入,我希望每个 selectInput 都显示选项的完整长度。但是,它们只显示在 splitLayout div 中。我怎样才能让 select 表单元素在其他所有内容之上显示下拉菜单。

Picture of the Problem

下面是我的源代码:

library(shiny)

app <- shinyApp(
  ui = fluidPage(fluidRow(h1('yo')),
                 fluidRow(
                   column(
                     4,
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     ),
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     ),
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     )

                   ),
                   column(
                     4,
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     ),
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     ),
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     )
                   ),
                   column(
                     4,
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     ),
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     ),
                     splitLayout(
                       cellWidths = c('50%', '25%', '25%'),
                       textInput('happy', label = 'mood'),
                       selectInput('letter', 'which', LETTERS),
                       selectInput('letter', 'what', letters)
                     )
                   )

                 )),

  server = function(input, output) {
  }
)

runApp(app)

最佳答案

这是使用 div 控制小部件对齐的另一种方法。这不会与 selectInput 框中的 choices 重叠。

library(shiny)

shinyApp(
  ui = fluidPage(fluidRow(h1('yo')),
                 fluidRow(
                   column(4,
                          div(style = "display:inline-block; width: 35%;",
                              textInput('happy', label = 'mood')),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'which', LETTERS)),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'what', letters))
                          ),

                   column(4,
                          div(style = "display:inline-block; width: 35%;",
                              textInput('happy', label = 'mood')),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'which', LETTERS)),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'what', letters))
                          ),

                   column(4,
                          div(style = "display:inline-block; width: 35%;",
                              textInput('happy', label = 'mood')),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'which', LETTERS)),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'what', letters))
                          )
                   ),

                 fluidRow(
                   column(4,
                          div(style = "display:inline-block; width: 35%;",
                              textInput('happy', label = 'mood')),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'which', LETTERS)),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'what', letters))
                   ),

                   column(4,
                          div(style = "display:inline-block; width: 35%;",
                              textInput('happy', label = 'mood')),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'which', LETTERS)),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'what', letters))
                   ),

                   column(4,
                          div(style = "display:inline-block; width: 35%;",
                              textInput('happy', label = 'mood')),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'which', LETTERS)),
                          div(style = "display:inline-block; width: 25%;",
                              selectInput('letter', 'what', letters))
                          )
                   )

                 ),

  server = function(input, output) {
  }
)

编辑:没有 div 或任何样式选项的替代解决方案。

对齐小部件的另一种更简单的方法是对每个框使用 column,如下所示。

library(shiny)

shinyApp(
  ui = fluidPage(fluidRow(h1('yo')),
                 fluidRow(
                   column(2,
                          textInput('happy', label = 'mood')),
                   column(1,
                          selectInput('letter', 'which', LETTERS)),
                   column(1,
                          selectInput('letter', 'what', letters)),
                   column(2,
                          textInput('happy', label = 'mood')),
                   column(1,
                          selectInput('letter', 'which', LETTERS)),
                   column(1,
                          selectInput('letter', 'what', letters)),
                   column(2,
                          textInput('happy', label = 'mood')),
                   column(1,
                          selectInput('letter', 'which', LETTERS)),
                   column(1,
                          selectInput('letter', 'what', letters))
                   ),

                 fluidRow(
                   column(2,
                          textInput('happy', label = 'mood')),
                   column(1,
                          selectInput('letter', 'which', LETTERS)),
                   column(1,
                          selectInput('letter', 'what', letters)),
                   column(2,
                          textInput('happy', label = 'mood')),
                   column(1,
                          selectInput('letter', 'which', LETTERS)),
                   column(1,
                          selectInput('letter', 'what', letters)),
                   column(2,
                          textInput('happy', label = 'mood')),
                   column(1,
                          selectInput('letter', 'which', LETTERS)),
                   column(1,
                          selectInput('letter', 'what', letters))
                 )

                 ),

  server = function(input, output) {
  }
)

关于css - Shiny 的 R - 允许滚动条在 div 之上而不是在 div 之内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46495439/

相关文章:

R - Ubuntu 上的 Shiny 服务器

javascript - 如何使用 JavaScripts 按中心对齐 2 张图像

r - selectInput 中的选项显示在传单 map 上

javascript - 粘性标题没有完全固定

r - 如何在 R 中创建条形图,其中 y 轴为频率而不是密度?

r - 理解水平: is levels not same as unique()

在 Shiny 启动时跨选项卡呈现传单标记

javascript - textArea 的 Shiny 绑定(bind) - 无法设置初始值

css - 如何覆盖被重写的类——CSS

html - CSS3 从左到右的过渡不起作用