[英]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.