我正在尝试减小 Shiny 应用程序侧栏中菜单子项的字体大小。
这是我的代码:
library(shiny)
library(shinydashboard)
header <- dashboardHeader(
title = "Test Dashboard"
)
sidebar <- dashboardSidebar(
sidebarMenu (
menuItem("Test",startExpanded = TRUE,
menuSubItem("Dashboard", tabName = "tab"),
menuSubItem("Link")
)
)
)
body <- dashboardBody(
tags$style(HTML(".main-sidebar { font-size: 12px; }")),
tabItems(
tabItem(tabName = "tab",
box(title = "Table", width = 10, status = "warning", DT::dataTableOutput("table"))
)
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$table = DT::renderDataTable({
DT::datatable(tabledata)
})
}
shiny::shinyApp(ui, server)
但是,通过使用tags$style(HTML(".main-sidebar { font-size: 12px; }"))
,我只缩小了主菜单项的字体大小,当我展开主项时,菜单子项的字体大小仍然是默认的。
请提前提供建议和感谢。
library(shiny)
library(shinydashboard)
header <- dashboardHeader(
title = "Test Dashboard"
)
sidebar <- dashboardSidebar(
sidebarMenu (
menuItem("Test",startExpanded = TRUE,
menuSubItem("Dashboard", tabName = "tab"),
menuSubItem("Link")
)
)
)
body <- dashboardBody(
tags$style(HTML(".main-sidebar { font-size: 12px!important; }
.treeview-menu>li>a { font-size: 12px!important; }")),
tabItems(
tabItem(tabName = "tab",
box(title = "Table", width = 10, status = "warning", DT::dataTableOutput("table"))
)
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$table = DT::renderDataTable({
DT::datatable(tabledata)
})
}
shiny::shinyApp(ui, server)
尝试使用谷歌浏览器和检查器导航到元素。在那里你可以看到它!小心。如果字体大小来自 AdminLTE,你必须用 覆盖它!important
,否则什么都不会改变
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句