Pet*_*erJ 3 r shiny selectinput
我想删除/减少闪亮中选择输入的标签和选择选项之间的空间。我还想减少两个不同选择输入之间的空间。
我尝试将 selectinputs 包装为 div 样式,并将边距和填充设置为 0。这没有效果,但我可能做错了。请参阅下面的代码。
ui <- fluidPage(
theme = shinytheme("sandstone"),
sidebarLayout(
sidebarPanel(
div(style = "font-size:12px; margin: 0px; padding: 0px",
selectInput(
"select1",
label = h5("Selection 1"),
choices = c("a", "b", "c"),
selectize = TRUE
),
selectInput(
"select2",
label = h5("Selection 2"),
choices = c("a", "b", "c"),
selectize = TRUE
)
)
),
mainPanel(
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
要减少标签和下拉列表之间的空间,请使用以下 CSS:
.shiny-input-container > label {margin-bottom: -15px;}
Run Code Online (Sandbox Code Playgroud)
要减少两个选择输入之间的空间,您可以div
在它们之间插入一个带有负号的样式margin-top
。
library(shiny)
library(shinythemes)
css <- "
.shiny-input-container > label {margin-bottom: -15px;}"
ui <- fluidPage(
theme = shinytheme("sandstone"),
tags$head(
tags$style(HTML(css))
),
sidebarLayout(
sidebarPanel(
selectInput(
"select1",
label = h5("Selection 1"),
choices = c("a", "b", "c"),
selectize = TRUE
),
div(style = "margin-top:-15px"),
selectInput(
"select2",
label = h5("Selection 2"),
choices = c("a", "b", "c"),
selectize = TRUE
)
),
mainPanel(
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)