我创建了一个带有一些按钮的UI页面,并且checkboxInput按钮有两个问题:
checkboxInput('comissions', label = "Comissions", width = "10%")
更改width =“X%”不会改变任何内容,“Xpx”也是如此。我怀疑这是由于固定的列宽,但X%的变化适用于其他按钮。
第二个问题是按钮看起来像这样:
我希望它居中,而不是在左栏。
感谢您的帮助,
这是一种使复选框居中的方法,但它需要width = "100%"
。
library(shiny)
ui <- basicPage(
fluidRow(
column(4,
sliderInput("costs", "Costs", min = 1, max = 10, value = 1)),
column(4, style = "text-align: center;",
checkboxInput("comissions", label = "Comissions", width = "100%")),
column(4,
sliderInput("periods", "Number of periods", min = 1, max = 10, value = 1))
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
通过改变宽度,我不知道你期望看到什么?
要控制复选框输入周围的空白区域及其垂直对齐方式:
library(shiny)
ui <- basicPage(
fluidRow(
column(12,
div(style = "display: inline-block;",
sliderInput("costs", "Costs", min = 1, max = 10, value = 1)
),
div(style = "display: inline-block; margin-left: 20px; margin-right: 20px; vertical-align: -20px;",
checkboxInput("comissions", label = "Comissions", width = "100%")
),
div(style = "display: inline-block;",
sliderInput("periods", "Number of periods", min = 1, max = 10, value = 1)
)
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)