【问题标题】:Shiny page title and image闪亮的页面标题和图像
【发布时间】:2018-08-05 02:50:58
【问题描述】:

我的用户界面代码如下:

ui <- navbarPage(
theme = shinytheme("paper"),
title = div(img(src="ballerlablogo.png", style="margin-top: -14px;", height = 50)),

...

)

效果很好,但是网页标签上的标题如下所示:

有没有办法让页面标题为“Baller Lab”而不去掉导航栏中的图像或在导航栏中添加“baller lab”文本?

这是该网站的链接:BallerLab.us

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    使用fluidPage,您可以使用tags$head 修改网页标签上的标题

    library(shiny)
    library(shinythemes)
    ui <- fluidPage(
      theme = shinytheme("paper"),
      tags$head(HTML("<title>Baller Lab</title>")), #Without company logo
      #tags$head(HTML("<title>Baller Lab</title> <link rel='icon' type='image/gif/png' href='ballerlablogo.png'>")), #WIth company logo
      navbarPage(title = div(img(src="ballerlablogo.png", style="margin-top: -14px;", height = 50))))
    
    server <- function(input, output, session) {}
    
    shinyApp(ui, server)
    

    【讨论】:

    • 不混合 Shiny 函数和HTML:tags$head(tags$title("My Title"))
    • @Kalaschnik 如果您想添加带有徽标的标题怎么办?
    • @a-suliman 上次我检查标题元素时只允许 unicode 纯文本。但是,这允许添加表情符号:tags$head(tags$title("? My Title"))
    • @Kalaschnik 评论的第二个选项允许添加徽标。
    • @a-suiman 啊哈,我们在谈论网站图标!我以为您想在标题元素中放置图像!好吧,您也可以将 favicon 堆叠在嵌套的 R 函数中:tags$head(tags$link(rel = "icon", type = "image/gif/png", href = "ballerlablogo.png")), tags$head(tags$title("Baller Lab"))
    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 2020-10-25
    相关资源
    最近更新 更多