使用bs4Dash包时在shinydashboard标题中添加徽标

wpx232ag  于 2022-12-06  发布在  其他
关注(0)|答案(1)|浏览(112)

在 Jmeter 板标题中添加徽标不适用于bs4Dash库。有什么建议吗?

# app.R ##
library(shiny)
library(shinydashboard)
library(bs4Dash)
library(shinydashboardPlus)


ui <- dashboardPage(
  dashboardHeader(# removed some lines
    title = div("", id = "home_logo", a(href = "#Home",
                                         )),
    controlbarIcon = shiny::icon("filter")
    
  ),
  dashboardSidebar(
    collapsed = TRUE
    
    
  ),
  dashboardBody(
    # new code  9 lines
    tags$head(tags$style(HTML('
        /* navbar (rest of the header) */
        .skin-blue .main-header .navbar {
                                background-image:url("https://www.r-project.org/logo/Rlogo.png");
                                background-position-x: 2%;
                                background-size: 70px 40px;
                                background-repeat: no-repeat;
                                background-color:#000;
                              }
        /* logo */
        .skin-blue .main-header .logo {
                              background-color: white;
                              }

        /* logo when hovered */
        .skin-blue .main-header .logo:hover {
                              background-color: white;
                              }

        /* navbar (rest of the header) */
        .skin-blue .main-header .navbar {
                              background-color: white;
        }  
                               
        /* body */
        .content-wrapper, .right-side {
                              background-color: white;
                                 }

        /* main sidebar */
        .skin-blue .main-sidebar {
                              background-color: snow;
        }
        /* toggle button when hovered  */                    
         .skin-blue .main-header .navbar .sidebar-toggle{
                              background-color: black;
         }
        /* toggle button when hovered  */                    
         .skin-blue .main-header .navbar .sidebar-toggle:hover{
                              background-color: black;
                              }
                              
       
       
                              '))),
    
    tags$style(type="text/css",".sidebar-toggle{ position: absolute;
}
.skin-white .main-header .logo, .skin-blue .main-header .logo, .skin-blue .main-header .logo:hover{
    background-color: white;}"),
    
    
    
    
  ),
  
  controlbar = dashboardControlbar(id = "dashboardControlbarID", collapsed = TRUE,skin = "black",icon = icon("filter"))
  
  
  
  
  
)

server <- function(input, output) {}

shinyApp(ui, server)
yptwkmov

yptwkmov1#

使用img-标签如何:

title = tags$img(src = 'https://www.r-project.org/logo/Rlogo.png', title = "Rlogo", height = "40px")

完整示例,包括链接:

library(shiny)
library(bs4Dash)

ui <- dashboardPage(
  dashboardHeader(title = a(target="_blank", href = 'https://www.r-project.org/',
                              img(src = 'https://www.r-project.org/logo/Rlogo.png', title = "Rlogo", height = "40px"),
                              style = "padding-top:5px; padding-bottom:5px;")),
  dashboardSidebar(),
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(plotOutput("plot1", height = 250)),
      
      box(
        title = "Controls",
        sliderInput("slider", "Number of observations:", 1, 100, 50)
      )
    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)
  
  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
}

shinyApp(ui, server)

相关问题