首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带图像的样式下载按钮

带图像的样式下载按钮
EN

Stack Overflow用户
提问于 2020-07-27 02:03:52
回答 1查看 100关注 0票数 2

我想在下载按钮中显示图像,就像这个链接- https://jsfiddle.net/flexmonster/67yx16ec/。在这个链接中有“到Excel”按钮,我想复制相同的闪亮。我用下面的代码尝试了一下,但是没有成功。

代码语言:javascript
复制
library(shiny)
library(shinydashboard)
ui <- shinyUI( dashboardPage(
  dashboardHeader(
    title="Styling Download Button"
  ),
  dashboardSidebar(
    tags$style(type="text/css", "#download1 {color: black; background-image: url(https://www.flexmonster.com/flexmonster/toolbar/img/toolbar/menu_xls_large.png);}"),
    downloadButton("download1", label="Download with style", class = "butt1")
  ),
  dashboardBody()
))
#server.r
server <- shinyServer(function(input, output) {})

shinyApp(ui, server)
EN

回答 1

Stack Overflow用户

发布于 2020-07-27 16:29:21

我会推荐一个SVG图标。它们的质量更好。下载SVG excel图标文件,并将其放入应用程序的www子文件夹中。例如,我下载了this one并将其命名为icon-excel.svg.

代码语言:javascript
复制
library(shiny)
library(shinydashboard)

ui <- shinyUI( dashboardPage(
  dashboardHeader(
    title = "Styling Download Button"
  ),
  dashboardSidebar(
    downloadButton(
      "download1",
      label = tagList(
        tags$img(src = "icon-excel.svg", width = "30", height = "30"),
        tags$span("Download", style = "color: #007732; font-weight: bold")
      )
    ),
    tags$script(HTML("$('#download1').css('padding-left',2).find('>i').remove();"))
  ),
  dashboardBody()
))
#server.r
server <- shinyServer(function(input, output) {})

shinyApp(ui, server)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63103832

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档