消除仪表板中splitLayout中列之间的间隙

时间:2018-07-10 10:32:29

标签: css r shiny shinydashboard

我正在使用闪亮仪表板包中splitLayout()中的dashboardSidebar()函数。当我这样做时,我的splitLayout()中的输入之间会有很大的差距。

当我使用香草光泽时,我可以使用参数cellArgs = list(style="padding: 0px")控制此间隙,但这似乎在dashboardSidebar()中具有不同的作用。

问题: 如何控制splitLayout()dashboardSidebar()内部的输入之间的间隔?

这是一个MRE,显示了我使用填充的失败尝试

library(shinydashboard)
library(shiny)

sidebar <- dashboardSidebar(width=400,
                            sidebarMenu(
                              menuItem("Default", tabName = "dashboard", icon = icon("dashboard"),startExpanded = T,
                                       splitLayout(cellWidths = c(100,100,100,100),
                                                   textInput("a1",label=NULL,value = 1),
                                                   textInput("a2",label=NULL,value = 2),
                                                   textInput("a3",label=NULL,value = 3),
                                                   textInput("a4",label=NULL,value = 4)
                                       ),
                                       splitLayout(cellWidths = c(100,100,100,100),cellArgs = list(style="padding: 0px"),
                                                   textInput("b1",label=NULL,value = 1),
                                                   textInput("b2",label=NULL,value = 2),
                                                   textInput("b3",label=NULL,value = 3),
                                                   textInput("b4",label=NULL,value = 4)
                                       ),
                                       #see the effect of padding
                                       splitLayout(cellWidths = c(100,100,100,100),cellArgs = list(style="padding: 20px"),
                                                   textInput("c1",label=NULL,value = 1),
                                                   textInput("c2",label=NULL,value = 2),
                                                   textInput("c3",label=NULL,value = 3),
                                                   textInput("c4",label=NULL,value = 4)
                                       )
                              )
                            )
)

body <- dashboardBody(

)

# Put them together into a dashboardPage
ui <- dashboardPage(
  dashboardHeader(title = "Padding demo",titleWidth=400),
  sidebar,
  body
)
server <- function(input, output) {


}
shinyApp(ui,server)

1 个答案:

答案 0 :(得分:1)

您的问题不是splitCells的填充-可以正常工作。与输入有关的还有更多的填充。要删除此代码,您可以添加以下代码

body <- dashboardBody(
  tags$head(
    tags$style(
      ".shiny-input-container{padding:0px !important;}"
    )
  )
)

希望这会有所帮助