首页 > 解决方案 > 在闪亮仪表板标题部分的同一行中添加图像和标题

问题描述

我创建了一个闪亮的仪表板,我在其中设置了titleWidth侧边栏宽度 = 0,以便隐藏它们。然后我想在标题部分的左角添加一个完全适合标题部分的图像,然后在同一行但在右上角添加标题。正如您现在看到的,标题部分变得更大,并且标题似乎比图像低一行。这是我的代码:

在此处输入图像描述

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
dbHeader <- dashboardHeaderPlus(
    titleWidth = "0px",
    tags$li(a(href = 'http://https://www.uow.edu.au/',
              img(src = 'download.png',
                  height = "55px",width="232px"),
              style = "padding-top:0px; padding-bottom:0px; padding-right:1690px;padding-left:90px;"),
            class = "dropdown")
    
)
shinyApp(
    ui = dashboardPagePlus(
        header = dbHeader,
        sidebar = dashboardSidebar(width = "0px"),
        body = dashboardBody(
            useShinyjs(),
            
            tags$head(tags$style(".skin-blue .main-header .logo { padding: 0px;}")),
            
            tags$head(tags$style(HTML(
                '.myClass { 
        font-size: 25px;
        line-height: 50px;
        text-align: left;
        font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
        padding:  1500px;
        padding-bottom: 0 0px;
        padding-top: 0 0px;

        overflow: hidden;
        color: black;
      }
    '))),
            tags$script(HTML('
      $(document).ready(function() {
        $("header").find("nav").append(\'<span class="myClass"> Life,Death & Statins </span>\');
      })
     '))
            
            
            
        )
        
    ),
    server<-shinyServer(function(input, output,session) { 
        hide(selector = "body > div > header > nav > a")
        
    }
    )
)

标签: rshinyshinydashboard

解决方案


也许你正在寻找这个。您可以使用填充和边距来获得适当的间距。

mytitle <- paste0("Life, Death and Statins")

dbHeader <- dashboardHeaderPlus(
  titleWidth = "0px",

  tags$li(a(href = "https://www.mit.edu/", #   'http://https://www.uow.edu.au/',
            div(style = "margin-left:-15px;margin-bottom:-44px;margin-top:-15px;padding: 0px 1190px 0px 0px ; width: 290px;",
                img(src = 'YBS.png', height = "55px",width="232px")),
            div(style="display: inline; padding: 0px 90px 0px 750px ; font-size: 40px ; width: 300px;",HTML(mytitle, "<br>"))
            ),
          class = "dropdown")
)

输出


推荐阅读