简体   繁体   English

在闪亮仪表板的标题部分的同一行中添加图像和标题

[英]Add image and title in the same row of the header section of a shiny dashboard

I create a shiny dashboard in which I have set titleWidth and sidebar width = 0 in order to have them hidden.我创建了一个闪亮的仪表板,我在其中设置了titleWidth和侧边栏宽度 = 0 以便将它们隐藏。 Then I want to add an image in the left corner of the header section which will completely fit to the header section and then the title in the same row but in the right corner.然后我想在标题部分的左角添加一个图像,该图像将完全适合标题部分,然后在同一行中添加标题,但在右上角。 As you can see now the header section became bigger and also the title seems to be a row lower than the image.正如您现在所看到的,标题部分变得更大,而且标题似乎比图像低一行。 Here is my code:这是我的代码:

在此处输入图片说明

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")
        
    }
    )
)

Perhaps your are looking for this.也许你正在寻找这个。 You can play with padding and margins to get appropriate spacing.您可以使用填充和边距来获得适当的间距。

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")
)

输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在闪亮仪表板标题的同一行中设置图像、标题和按钮 - Set image, title and buttons in the same line of the header of a shiny dashboard 在 shiny 仪表板 header 部分中添加 shiny 小部件 - Add a shiny widget inside shiny dashboard header section 在Shiny Dashboard中设置标题/标题 - Set title/header in Shiny Dashboard 在 shiny 仪表板中永久更改标题 header 颜色 - Change the title header color permanently in shiny dashboard 根据不同的 tabpanels 显示不同的图像作为闪亮仪表板的标题 - Display different image as title of shiny dashboard based on different tabpanels 以闪亮的高度显示图像和标题 - Display image and title on same height in shiny 如何在 R Shiny Dashboard 上的固定标题上/带有/在固定标题上显示固定图像 - How to display a fixed image on/with/upon a fixed header on R Shiny Dashboard 通过单击现有的切换按钮完全隐藏 shiny 仪表板的左侧边栏而不影响标题部分 - Totally hide left sidebar of shiny dashboard by clicking on existing toggle button without affecting the title section 删除 shiny 数据表 excel Z78E6221F6393D135668?ZFCED98 中 header 上方的“标题”行 - Remove “title” row above header in shiny datatable excel output? 当用户将鼠标悬停在 shiny 仪表板的 header 部分上时,停用颜色变化 - Deactivate the change of color when the user hovers over the header section of a shiny dashboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM