闪亮的复选框按钮宽度和居中

Ark*_*i w 3 r shiny shinydashboard

我创建了一个带有一些按钮的 UI 页面,并且 checkboxInput 按钮有两个问题:

  checkboxInput('comissions', label = "Comissions", width = "10%")
Run Code Online (Sandbox Code Playgroud)

更改宽度=“X%”不会改变任何内容,与“Xpx”相同。我怀疑这是由于固定的列宽造成的,但 X% 的变化对于其他按钮效果很好。

第二个问题是按钮看起来像这样:

在此输入图像描述

我希望它居中而不是在左栏中。

感谢您的帮助,

Sté*_*ent 5

这是一种使复选框居中的方法,但它需要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)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我不知道你希望通过改变宽度看到什么?


编辑

要控制复选框输入周围的空白及其垂直对齐方式:

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)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述