簡體   English   中英

R Shiny-向框標題添加“刪除”按鈕

[英]R Shiny - Adding a 'remove' button to the box header

我正在嘗試在下面方框的標題中添加標題並刪除按鈕:

在此處輸入圖片說明

這是重現該框的代碼:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    tags$style(HTML("

                  .my_class .box.box-solid.box-primary>.box-header {
                    background:rgba(0,128,128,.5);
                    height: 30px;
                    padding-top: 0px
                  }

                    .learner-title {margin-top:5px}

                    .box.box-solid.box-primary{
                    border-color:rgb(0,128,128);
                    background:rgba(0,128,128,.1)
                    }

                    ")),
    fluidRow(
      tags$div(class = "my_class", 
               box(width = 6, title = div(h4(class = "learner-title", "Box Title"), 
                                          div(class = "box-tools pull-right",
                                              tags$button(class = paste0("btn btn-box-tool"),
                                                          `data-widget` = "remove",
                                                          shiny::icon("remove")
                                                          ))
                                          ), status = "primary", solidHeader = TRUE,
                   "Box content"
                   )
               )
    )
  )
)


server <- function(input, output) {}

shinyApp(ui, server)

雖然刪除按鈕有效,但我希望它位於框的右上角,並位於標題的上方。 在上面的代碼中,我嘗試使用class = "box-tools pull-right"來實現正確的對齊,但這似乎不起作用。

嘗試為按鈕添加此CSS

.box-tools.pull-right {
  position: absolute;
  right: 0;
  top: 0;
}

.box-tools.pull-right選擇器不是最好的選擇,如果為按鈕提供了更多唯一的ID /類並將其用作標識符,則更好。 但是無論如何,這些CSS規則應該可以解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM