如何增加 Shiny 仪表板中标签和输入之间的距离?
library(shiny)
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")
))
)
)
server <- shinyServer(function(input, output) { NULL })
shinyApp(ui = ui, server = server)
最佳答案
尝试在 selectInput
之前添加此行,并确保在 selectInput
之后添加额外的括号以关闭 tags$div
。
tags$div(id = "div_test", tags$style("#div_test div {margin-left: 20px}")
所以会是:
column(4,
tags$div(id = "div_test", tags$style("#div_test div {margin-left: 20px}"),
selectInput(inputId = "options", label = "some text",
choices = list(a = 0, b = 1))),
)
基本上,它的作用是在 selectInput
之前创建一个额外的 div
,我们将使用它来缩进以增加标签和选择输入之间的间距。
关于r - 增加 Shiny 仪表板中侧标签和 Shiny 小部件之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67259664/