css - Shiny 的 selectInput 旁边的标签

标签 css r user-interface label shiny

我有这样一个 Shiny 的应用程序:

服务器.R:

    library(shiny)

    function(input, output) { NULL }

和 ui.R:

    library(shiny)  


    pageWithSidebar( 

       headerPanel("side-by-side"), 

     fluidRow(

        column(2),
        column(4,
           wellPanel(
               selectInput(inputId = "options", label = "some text", 
                           choices = list(a = 0, b = 1)))   
           )
      ),

      fluidRow( 
         h3("bla bla")
     )
    )

而且我希望 selectInput 的标签在它旁边,而不是在上面。你知道怎么做吗?

我找到了这个:Positioning Shiny widgets beside their headers 但它对我不起作用。

最佳答案

有多种方法可以做到这一点,这里是一种:

library(shiny)

server <- shinyServer(function(input, output) { NULL })
ui <- shinyUI(
  pageWithSidebar( 

    headerPanel("side-by-side"), 

    sidebarPanel(
    fluidRow(
      tags$head(
        tags$style(type="text/css", "label.control-label, .selectize-control.single{ display: table-cell; text-align: center; vertical-align: middle; } .form-group { display: table-row;}")
      ),
      column(2),
      column(4,
               selectInput(inputId = "options", label = "some text", 
                           choices = list(a = 0, b = 1))
      )
    )),
    mainPanel(
    fluidRow( 
      h3("bla bla")
    ))
  )
)

shinyApp(ui=ui,server=server)

如果您不想弄乱 Shiny 的默认 CSS,您可以将标签留空并在其旁边创建一个标签,而不是将现有标签强制放在一边。

关于css - Shiny 的 selectInput 旁边的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33960035/

相关文章:

java - 通过拖动角来调整 gui 元素的大小

html - 箭头一溢出就消失 :auto element is added to other div

r - 检查R中的value == integer(0)

r - 按财政季度计算 R 中两个日期之间事件的记录

R - 根据数据框中的条件按组设置值

c++ - 建议我如何使用预定义颜色创建这样的颜色选择器

javascript - img 的最大高度和宽度,负边距/溢出而不是缩放?

css - 如何使用css对齐多行文本?

css - 在 Bootstrap 中完全居中表单

c++ - Qt - 拖动标题栏时防止窗口调整大小