【问题标题】:Customize Hyper Link into a Button Shiny R将超链接自定义为按钮 Shiny R
【发布时间】:2021-11-11 18:50:03
【问题描述】:

我正在尝试将许多超链接自定义为闪亮的操作按钮。我发现了一些关于堆栈溢出的代码,显示了如何在 CSS/HTML 中执行此操作。但是,如果我想让它应用于所有带有 class== "button" 的链接,我对在我闪亮的代码中放置它的位置有点困惑。

下面是按钮的html代码

.button {
  font: bold 11px Arial;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
}

下面是一个闪亮的应用程序。我应该在哪里插入上面的代码,这样当我在锚标记中调用“class= Button”时,超链接就会看起来像一个按钮。

ui <- fluidPage(

  titlePanel("Hello Shiny!"),

  
  sidebarLayout(

      textOutput('test')
    ),

    
    mainPanel(
       a("Click Here To Learn More",href="https://google.com",  class = "button")

    
    )
  )
)

感谢您的帮助

【问题讨论】:

    标签: html css r shiny shinydashboard


    【解决方案1】:

    你可以试试这个

    CSS <- "
    .button {
      font: bold 11px Arial;
      text-decoration: none;
      background-color: #EEEEEE;
      color: #333333;
      padding: 2px 6px 2px 6px;
      border-top: 1px solid #CCCCCC;
      border-right: 1px solid #333333;
      border-bottom: 1px solid #333333;
      border-left: 1px solid #CCCCCC;
    }"
    
    ui <- fluidPage(
      
      titlePanel("Hello Shiny!"),
      tags$head(
        tags$style(HTML(CSS))
      ),
      
      sidebarLayout(
        sidebarPanel(textOutput('test')),
        
        mainPanel(
          a("Click Here To Learn More",href="https://google.com",  class = "button")
        )
      )
    )
    
    server <- function(input, output) {
      output$test <- renderText({paste("Test 1")})
    }
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-29
      • 1970-01-01
      • 2017-03-29
      • 2017-06-22
      • 1970-01-01
      • 2014-08-09
      相关资源
      最近更新 更多