首页 > 解决方案 > 如何在闪亮的应用程序中设置下载按钮的样式

问题描述

download button在我的Shiny应用程序中创建了一个。但是,我不想在单击时更改背景颜色,这不会发生在这里。下面是我的应用程序 -

library(shiny)
library(shinydashboard)
ui <- shinyUI( dashboardPage(
  dashboardHeader(
    title="Styling Download Button"
  ),
  dashboardSidebar(
    tags$style(type="text/css", "#download1 {background-color:rgba(0,0,0,0);color: black;font-family: Courier New}"),
    downloadButton("download1", label="Download with style", class = "butt1")
  ),
  dashboardBody()
))
#server.r
server <- shinyServer(function(input, output) {})

shinyApp(ui, server)

关于如何在点击时保持背景颜色完全相同的任何想法都将非常有帮助。

谢谢,

标签: rshinyshinyapps

解决方案


您可以确保#download1:active(单击时)样式等于#download1(正常)样式,如下所示。
在下面的示例中,我还确保它border-color是固定的,因此任何点击效果都不可见。

library(shiny)
library(shinydashboard)
ui <- shinyUI( dashboardPage(
  dashboardHeader(
    title="Styling Download Button"
  ),
  dashboardSidebar(
    tags$style(type="text/css",
               "#download1, #download1:active  {
      background-color:rgba(0,0,0,0);
      color: black;
      font-family: Courier New;
      border-color: #ddd;
      -webkit-box-shadow: 0px;
      box-shadow: 0px;
    }
   "),
    downloadButton("download1", label="Download with style", class = "butt1")
  ),
  dashboardBody()
))
#server.r
server <- shinyServer(function(input, output) {})

shinyApp(ui, server)

推荐阅读