r - 如何垂直对齐 R Shiny 单选按钮
问题描述
请就如何将下面应用程序中的按钮排列成一条整齐的直线,同时仍继承列的“中心”对齐方式提供任何指导?我希望保持列的“中心”对齐,以便按钮在“中心对齐标题”下对齐,但是这会以不稳定的方式排列每个选项,具体取决于选项的长度。
library(shiny)
app <- shinyApp(
ui = fluidPage(
column(4),
column(4,
fluidRow(
column(12,
align = 'center',
h6('Center Aligned Title')
)
),
fluidRow(
column(12,
align = 'center',
# align = 'left', # This justifies/arranges the buttons neatly
# but not underneath "Center Aligned Title"
radioButtons(
inputId = 'my_btns',
label = NULL,
choices = c('abc','defg','hijllm','no'),
selected = character(0),
inline = F
)
)
)
),
column(4)
),
server = function(input, output) {}
)
runApp(app)
解决方案
您可以插入align = 'center'
第二个column()
并使用 CSS 来对齐 flexbox 中的单选按钮,如下所示:
app <- shinyApp(
ui = fluidPage(
tags$head(
tags$style(HTML("
#my_btns, #my_div {
display: flex;
justify-content: center;
}"
))
),
fluidRow(
column(12,
align = 'center',
h6('Center Aligned Title')
)
),
fluidRow(
column(12,
div(
radioButtons(
inputId = 'my_btns',
label = NULL,
choices = c('abc','defg','hijllm','no'),
selected = character(0),
inline = F
), id = "my_div")
)
)
),
server = function(input, output) {}
)
结果:
推荐阅读
- ios - 从特殊字符范围创建字符串时出现 Swift 错误
- python - 如何获得返回的字符串长度?
- c++ - W10/Wins32 C++ 如何确定哪些字符可用于写入 HDC
- c# - 如何将 HttpClientHandler 传递给现有的 HttpClient?
- go - golang中没有固定长度的数组
- windows - 为什么我的 powershell 显示为盒装而不是 V 形?
- python - 谷歌下一步按钮上的硒驱动程序,NoSuchElementException
- javascript - 根据另一个下拉选择显示/隐藏下拉列表
- php - Mac 上的 XAMPP 安装问题 // bitnami-first-boot-123456
- android - Salesforce Marketing Cloud 是否支持 Android 应用程序链接