gpt4 book ai didi

css - 删除 dashboardSidebar 中 splitLayout 中列之间的间隙

转载 作者:太空宇宙 更新时间:2023-11-04 07:09:52 25 4
gpt4 key购买 nike

我在 shinydashboard 包的 dashboardSidebar() 中使用 splitLayout() 函数。当我这样做时,我的 splitLayout() 中的输入之间存在很大差距。

当我使用 vanilla shiny 时,我可以通过参数 cellArgs = list(style="padding: 0px") 来控制这个间隙,但这似乎在 dashboardSidebar( )

问题:如何控制 dashboardSidebar()splitLayout() 中输入之间的间隙?

这是一个 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)

最佳答案

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

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

希望对你有帮助

关于css - 删除 dashboardSidebar 中 splitLayout 中列之间的间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51262979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com