div align right checkboxInput在闪亮的仪表板中不起作用

时间:2016-06-01 08:59:47

标签: checkbox shiny right-align

我闪亮的仪表板上有checkboxInput,我试图将它对齐到框内项目的标题内。对于较小的盒子(宽度为6),对齐是正确的,但是对于宽度为12的盒子,我总是重新对齐列值,复选框输入仍然在盒子的中间。代码如下:

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
    skin = "green",
    dashboardHeader(
        title = "TEST", titleWidth = 225
        ),
    dashboardSidebar(
        menuItem("TRENDS", tabName = "vactr", icon = shiny::icon("line-chart"))
        ),
    dashboardBody(
        tabItems(
            tabItem(
                tabName = "vactr",
                fluidRow(
                    box(
                        width = 12, status = "info", title = 
                            fluidRow(
                                column(6, "Trend - Usage of space",br(),
                                       div(downloadLink("downloadspacetrend", "Download this chart"), style = "font-size:70%", align = "left")),
                                column(6,
                                       div(checkboxInput(inputId = "spacetrendcheck", "Add to reports", value = FALSE),style = "font-size:70%",float = "right", align = "right", direction = "rtl"))
                                ),
                        div(plotOutput("spacetrend"), width = "100%", height = "400px", style = "font-size:90%;"),
                        uiOutput("spacetrendcomment")
                    )
                )

                )
            )
        )
    )


server <- function(input, output, session) {

}

shinyApp(ui = ui, server = server)

我想在框的右端添加“添加到报告”复选框。我尝试使用float和direction参数,但没有得到所需的输出。

1 个答案:

答案 0 :(得分:2)

您遇到以下问题:标题标题的宽度未设置为框的整个宽度。相反,它的宽度是根据它包含的元素计算的。这使得列(标题宽度为50%)也取决于元素。然而,你的元素并不是那么大,所以得到的div本身被分成两个同样大的列,但它们一起不会跨越整个盒子的宽度。

您可以将标题宽度修改为100%(框标题宽度),这样可以告诉列大,无论其内容是什么。 这是一个补充。

请注意,下面代码中的样式添加会影响所有标题。但我相信这绝不是一个问题。

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
  skin = "green",
  dashboardHeader(
    title = "TEST", titleWidth = 225
  ),
  dashboardSidebar(
    menuItem("TRENDS", tabName = "vactr", icon = shiny::icon("line-chart"))
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName = "vactr",
        fluidRow(
          box(width = 12, status = "info", title = 
            fluidRow(
              tags$style(".box-title {width: 100%;}"),
              column(6, "Trend - Usage of space",br(),
                div(downloadLink("downloadspacetrend", "Download this chart"), style = "font-size:70%", align = "left")),
              column(6,
                div(checkboxInput(inputId = "spacetrendcheck", "Add to reports", value = FALSE),style = "font-size:70%",float = "right", align = "right", direction = "rtl"))
            ),
            div(plotOutput("spacetrend"), width = "100%", height = "400px", style = "font-size:90%;"),
            uiOutput("spacetrendcomment")
          )
        )
      )
    )
  )
)

server <- function(input, output, session) {}

shinyApp(ui = ui, server = server)