gpt4 book ai didi

r - 如何在 Shiny 的 R 中将 SelectInput 向左对齐而没有多余的空格

转载 作者:行者123 更新时间:2023-12-05 05:44:13 24 4
gpt4 key购买 nike

我有这个 Shiny 的应用程序:

if (interactive()) {
shinyApp(
ui = fluidPage(
selectInput("variable", "Variable:",
c("Cylinders" = "cyl",
"Transmission" = "am",
"Gears" = "gear")),
tableOutput("data")
),
server = function(input, output) {
output$data <- renderTable({
mtcars[, c("mpg", input$variable), drop = FALSE]
}, rownames = TRUE)
}
)
shinyApp(
ui = fluidPage(
tags$style(type='text/css', ".selectize-input { font-size: 10px; line-height: 10px;} .selectize-dropdown { font-size: 10px; line-height: 10px; }"),
column(1,align="center"),
column(2,align="center",selectInput(width= "150px", "eshkol",h6("x"),c("q","a","c","x"))),
column(2,align="center",selectInput(width= "170px", "eshkol2",h6("y"),c("q","a","c","x"))),
column(2,align="center",selectInput(width= "1100px", "eshkol3",h6("z"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "80px", "eshkol4",h6("s"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "120px", "eshkol5",h6("t"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "120px", "eshkol6",h6("q"),c("q","a","c","x"))),


)
,
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}

我想重新排序 SelectInput - 删除 SelectInput 之间的多余空格并将其左对齐。我想保持我在代码中写的宽度。

enter image description here

欢迎任何建议

最佳答案

1 个不应用任何 css 的想法:

将第一个两个输入的列宽更改为 1 并按需要工作:

column(1,align="center",selectInput(width= "150px", "eshkol",h6("x"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "170px", "eshkol2",h6("y"),c("q","a","c","x"))),
column(2,align="center",selectInput(width= "1100px", "eshkol3",h6("z"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "80px", "eshkol4",h6("s"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "120px", "eshkol5",h6("t"),c("q","a","c","x"))),
column(1,align="center",selectInput(width= "120px", "eshkol6",h6("q"),c("q","a","c","x")))),

输出 - 与你显示的一样 - 为我工作

Output

关于r - 如何在 Shiny 的 R 中将 SelectInput 向左对齐而没有多余的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71636819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com