r - 在侧边栏菜单项之一上方添加空间
问题描述
我想在侧边栏菜单项之一上方添加空间。例如,下面示例中的“小部件”应显示在页面底部的侧边栏下方(意味着菜单顶部应该有空间)。我尝试这样做,tags$div(style = "margin-top: 50px;",
但没有得到想要的输出。
library(shinydashboard)
library(shiny)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
解决方案
你可以使用这个 CSS:
css <- "
.sidebar-menu li:not(:last-child) {
margin-bottom: 200px;
}
"
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tags$head(
tags$style(HTML(css))
),
tabItems(
......
推荐阅读
- reactjs - 如何限制用户登录时使用登录页面
- amazon-web-services - 云中的微积分器主机名问题
- unity3d - 在c#/Unity中销毁预制对象的特定子对象
- web-applications - 无需提示登录即可打开安全 Web AppBuilder
- excel - 如何将 vba sub 转换为函数?
- string - 在计算移动平均线时无法将字符串转换为浮点数
- http - http.Request.Clone() 不是深度克隆?
- javascript - 接口的按位“或”运算符是什么意思
- c++ - 不要使用 Bazel 破坏共享库的名称
- python - 将图像加载为 TensorFlow 数据集并输入 Keras model.fit 的工作流程?