【问题标题】:R, Shiny : Inline selectInputR,闪亮:内联选择输入
【发布时间】:2016-03-16 15:15:39
【问题描述】:

1 ) 我们如何将selectInput 定位在另一个旁边?我试过了:

# style.css
.general {
display: inline-block;
margin-left: auto;
margin-right: auto;
height: auto;
width : auto ;
white-space: nowrap ;}

# ui.R
...
tags$div(class = "general", selectInput(...), selectInput(...))
...

但它不起作用。

2) 我们如何将selectInput 的标签放置在selectInput 本身旁边?我找到了这个话题Positioning Shiny widgets beside their headers 但这是为应用程序的所有selectInput 设计的。我没有设法将tags$style(...) 中提供的代码仅用于我的应用程序的一个selectInput,而不是全部。我们该怎么做呢?

谢谢。

【问题讨论】:

    标签: css r widget position shiny


    【解决方案1】:

    只需尝试使用一个流畅的行和几列。由于总流体行宽 = 12,您最多可以放置 12 列,而无需任何额外的 css。例如:

    fluidRow(
    column(6, selectInput("S1", label = "S1")),
    column(6, selectInput("S2", label = "S2"))
    )
    

    【讨论】:

      【解决方案2】:

      我用一个简单的例子回答问题 1):

      # style.css
      .divleft {
        float : left;
        width : 50%;
      }
      
      .clearl {
        clear: left;
      }
      
      # ui.R
      library(shiny)
      
      shinyUI(fluidPage(
        tagList(
          tags$head(
            tags$link(rel="stylesheet", type="text/css",href="style.css")
          )
        ),
          sidebarLayout(
            sidebarPanel(
              selectInput("s1", "Select 1", 1:10),
              tags$div(
                tags$div(class = "divleft", selectInput("s2", label = "Select 2", 1:5, width = validateCssUnit("70%"))),
                tags$div(class = "divleft", selectInput("s3", label = "Select 3", 1:5, width = validateCssUnit("70%")))
              ),
              tags$div(class = "clearl",
                      selectInput("s4", "Select 4", 1:5)
                       )
              , width = 3),
            mainPanel(
              h3("Example")
            )
          )
        )
      )
      
      # server.R
      shinyServer(function(input, output, session) { })
      

      【讨论】:

        猜你喜欢
        • 2021-07-16
        • 1970-01-01
        • 2020-08-01
        • 2020-07-04
        • 2020-03-19
        • 2017-11-24
        • 2016-11-21
        相关资源
        最近更新 更多