我想改变我的 Shiny 应用程序的风格。我去了这里https://bootswatch.com/solar/并下载样式 .css file
:“Solar A 旋转 Solarized”。
library(shiny)
ui <- fluidPage(
titlePanel(tags$i(h1(strong("My Panel Title"),style = "font-family: 'times'; font-size: 82px"))),align="center",
navbarPage(theme="bootstrap.min.css",title = 'Methods',
tabPanel('One'),
tabPanel('Two'),
tabPanel('Three'),
tabPanel('Four'))
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
但是正如您所看到的,导航栏看起来很奇怪:
我该如何解决?
最佳答案
您链接到的主题是 Bootstrap 4 主题,但是 Shiny uses Bootstrap 3 .对于兼容的 Bootswatch 主题,请参阅他们的 v3 合集:https://bootswatch.com/3/ .
例如,通过 CDN 使用 v3 Flatly 主题:
library(shiny)
ui <- fluidPage(
titlePanel(tags$i(
h1(strong("My Panel Title"), style = "font-family: 'times'; font-size: 82px")
)),
align = "center",
navbarPage(
theme = "https://stackpath.bootstrapcdn.com/bootswatch/3.4.1/flatly/bootstrap.min.css",
title = 'Methods',
tabPanel('One'),
tabPanel('Two'),
tabPanel('Three'),
tabPanel('Four')
)
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
关于bootswatch 中的 CSS 样式不适用于 Shiny R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58683274/