【问题标题】:Changing the distance between the label text and a selectizeInput element in R Shiny?在 R Shiny 中更改标签文本和 selectizeInput 元素之间的距离?
【发布时间】:2018-05-24 15:01:26
【问题描述】:

我正在寻找一种方法来调整 Shiny 应用中 selectizeInput 元素上的标签空间。 不同的间距是在标签中插入复选框的结果。

我已经找到了提示here,但这没什么帮助。 这是一个例子:

library(shiny)

    ui <- fluidPage(
  tags$head(
    tags$style(HTML(
      "label { margin-bottom: 0px; }"
    ))
  ),
  fluidRow(
    column(2,
           selectizeInput("S1", label = checkboxInput(inputId = "chk1", label = p('Test - ', strong('Test:'))), c("A","B")),
           selectizeInput("S2", label = checkboxInput(inputId = "chk2", label = div(icon("filter"), strong('Test:'))), c("A", "B")),
           selectizeInput("S3", "Test:", c("A", "B")),
           selectizeInput("S4", "Test:", c("A", "B"))
    )))

server <- function(input, output){}

shinyApp(ui = ui, server = server)

This is the result

谢谢!

【问题讨论】:

    标签: css r shiny


    【解决方案1】:

    我认为应该这样做。

    library(shiny)
    
    ui <- fluidPage(
      tags$head(
        tags$style(HTML(
           ".checkbox {margin: 0}
            .checkbox p {margin: 0;}
            .shiny-input-container {margin-bottom: 0;}
           "
        ))
        # inlineCSS(".checkbox margin: 0;")
      ),
      fluidRow(
        column(2,
               selectizeInput("S1", label = checkboxInput(inputId = "chk1", label = p('Test - ', strong('Test:'))), c("A","B")),
               selectizeInput("S2", label = checkboxInput(inputId = "chk2", label = div(icon("filter"), strong('Test:'))), c("A", "B")),
               selectizeInput("S3", "Test:", c("A", "B")),
               selectizeInput("S4", "Test:", c("A", "B"))
        )))
    
    server <- function(input, output){}
    
    shinyApp(ui = ui, server = server)
    

    【讨论】: