在shiny中如何对齐不等长的checkbox?我想了个笨方法,在每个checkbox的string末尾加入若干个连续的空格(),但是在渲染的时候这些连续的空格都消失了。 示例代码如下
library(shiny)
# Generate sample data
tab_name = sapply(1:20, function(i) paste(rep(LETTERS[i], i), collapse = ""))
# Pad strings with extra blanks at the end to make them the same length
tab_name <- stringr::str_pad(tab_name, width = max(nchar(tab_name)), side = "right", pad = " ")
# ui
ui <- fluidPage(
# adjust the margin so they can align properly
tags$head(tags$style(".checkbox-inline {margin: 0 !important;}")),
checkboxGroupInput("tab", "Table Name",
choices = tab_name,
inline = TRUE)
)
server <- function(input, output){}
shinyApp(ui, server)
示例中只有第一列是对齐的,但由于每个checkbox的长度都不同,其他所有列的checkbox都不能对齐。
我想请问 如何保留checkbox末尾的空格,或者更进一步,如何在不加空格的基础上直接对齐不等长的checkbox。
如果哪里没说清楚我可以再补充信息,谢谢。