[英]shinydashboard, logo and title in navbar?
在shinydashboard
中是否有一種方法可以使標題和徽標都出現在導航欄中並且還有一個副標題?
一個 MWE 和一張我希望它成為圖書館(閃亮)圖書館(閃亮儀表板)的圖片
ui <- function(){
dashboardPage(
dashboardHeader(title=div(h4('Title'), h5('Subtitle')),
tags$li(a(img(src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", height="45px")), class="dropdown")),
dashboardSidebar(),
dashboardBody())}
server <- function(input, output, session) {}
shinyApp(ui=ui, server = server)
我知道將導航欄中的徽標帶到我必須使用的左側
.navbar-custom-menu {
float: left!important;}
但我不知道如何在導航欄中並排添加文本和徽標
嘗試這個:
library(shiny)
library(shinydashboard)
header_img <- div(
img(src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", height="45px"),
div(
class = "my-title",
h4('Title'), h5('Subtitle'),
tags$style(".my-title :is(h4, h5){color: white; font-weight: bold;}")
),
style = "display: flex;"
)
header <- htmltools::tagQuery(dashboardHeader(title = ""))
header <- header$
addAttrs(style = "position: relative")$ # add some styles to the header
find(".navbar.navbar-static-top")$ # find the header right side
append(header_img)$ # inject our img
allTags()
ui <- function(){
dashboardPage(
header,
dashboardSidebar(),
dashboardBody()
)
}
server <- function(input, output, session) {}
shinyApp(ui=ui, server = server)
還有另一個類似的問題: 如何在 Shinydashboard R 的儀表板標題的中心放置圖像?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.