我正在使用 R 闪亮,我试图在我的 ui 中为 selectInput 和 numericInput 设置相同的高度。我找到了这一行:
tags$style(type="text/css", ".selectize-input {line-height: 20px;}"),
Run Code Online (Sandbox Code Playgroud)
这改变了我所有 selectInputs 的高度。
是否有与 numericInput 类似的行?
谢谢
好吧,它没有特定的类,例如selectInput. 但是您仍然可以使用更通用的 class 获得相同的结果form-control。我们需要使用height而不是,无论如何line-height它都可以正常工作selectInput。
ui <- fluidPage(
tags$style(type = "text/css", ".form-control.shiny-bound-input,
.selectize-input {height: 70px;}"),
selectInput(inputId = "another_id",
label = "bar",
choices = c(1, 2)),
numericInput(inputId = "some_id",
label = "foo",
value = 1)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
如果要将某些 CSS 应用于特定输入,则需要使用它的id,因此该样式不适用于共享同一类的所有元素。在上面的示例中,如果您只想更改numericInput其idis的高度some_id,您将使用#some_id选择此元素,导致以下代码:
tags$style(type = "text/css",
"#some_id.form-control.shiny-bound-input {height: 70px;}")
Run Code Online (Sandbox Code Playgroud)