可排序的闪亮桶列表调整(宽度和间距)

问题描述 投票:0回答:1

有没有办法定义水平对齐的排名列表的宽度之间的比率(从这里变窄,到这里变宽)?我们可以调整/减少两个列表之间的间距吗?

来自

sortable
包的示例 (https://rstudio.github.io/sortable/)

## Example shiny app with bucket list

library(shiny)
library(sortable)

ui <- fluidPage(
  tags$head(
    tags$style(HTML(".bucket-list-container {min-height: 350px;}"))
  ),
  fluidRow(
    column(
      tags$b("Exercise"),
      width = 12,
      bucket_list(
        header = "Drag the items in any desired bucket",
        group_name = "bucket_list_group",
        orientation = "horizontal",
        add_rank_list(
          text = "Drag from here",
          labels = list(
            "one",
            "two",
            "three",
            htmltools::tags$div(
              htmltools::em("Complex"), " html tag without a name"
            ),
            "five" = htmltools::tags$div(
              htmltools::em("Complex"), " html tag with name: 'five'"
            )
          ),
          input_id = "rank_list_1"
        ),
        add_rank_list(
          text = "to here",
          labels = NULL,
          input_id = "rank_list_2"
        )
      )
    )
  ),
  fluidRow(
    column(
      width = 12,
      tags$b("Result"),
      column(
        width = 12,

        tags$p("input$rank_list_1"),
        verbatimTextOutput("results_1"),

        tags$p("input$rank_list_2"),
        verbatimTextOutput("results_2"),

        tags$p("input$bucket_list_group"),
        verbatimTextOutput("results_3")
      )
    )
  )
)

server <- function(input, output, session) {
  output$results_1 <-
    renderPrint(
      input$rank_list_1 # This matches the input_id of the first rank list
    )
  output$results_2 <-
    renderPrint(
      input$rank_list_2 # This matches the input_id of the second rank list
    )
  output$results_3 <-
    renderPrint(
      input$bucket_list_group # Matches the group_name of the bucket list
    )

}


shinyApp(ui, server)
shiny
1个回答
0
投票

bucket list 使用

flex
并充当两个排名列表的容器。如果您想要一个较窄的左侧列表和一个较宽的右侧列表,您可以调整 Flex 项目的比率(另请参阅 MDN 文档中的沿主轴线控制 Flex 项目的比率)。例如,如果左侧列表应占用可用空间的 1/3,右侧列表应占用 2/3,您可以添加

#rank-list-rank_list_1 { flex: 1 1 0; } #rank-list-rank_list_2 { flex: 2 1 0; }
如果您还希望两个列表之间的空间最小,可以将左侧列表的 

margin-right

 更改为 
0
,将右侧列表的 
margin-left
 更改为 
0
(请参阅有关 
margin
 的文章) 
在文档中)。

enter image description here

library(shiny) library(sortable) ui <- fluidPage( tags$head( tags$style(HTML(".bucket-list-container {min-height: 350px;} #rank-list-rank_list_1 { flex: 1 0 0; margin-right: 0; } #rank-list-rank_list_2 { flex: 2 0 0; margin-left: 0; }")) ), fluidRow( column( tags$b("Exercise"), width = 12, bucket_list( header = "Drag the items in any desired bucket", group_name = "bucket_list_group", orientation = "horizontal", add_rank_list( text = "Drag from here", labels = list( "one", "two", "three", htmltools::tags$div( htmltools::em("Complex"), " html tag without a name" ), "five" = htmltools::tags$div( htmltools::em("Complex"), " html tag with name: 'five'" ) ), input_id = "rank_list_1" ), add_rank_list( text = "to here", labels = NULL, input_id = "rank_list_2" ) ) ) ), fluidRow( column( width = 12, tags$b("Result"), column( width = 12, tags$p("input$rank_list_1"), verbatimTextOutput("results_1"), tags$p("input$rank_list_2"), verbatimTextOutput("results_2"), tags$p("input$bucket_list_group"), verbatimTextOutput("results_3") ) ) ) ) server <- function(input, output, session) { output$results_1 <- renderPrint( input$rank_list_1 # This matches the input_id of the first rank list ) output$results_2 <- renderPrint( input$rank_list_2 # This matches the input_id of the second rank list ) output$results_3 <- renderPrint( input$bucket_list_group # Matches the group_name of the bucket list ) } shinyApp(ui, server)
    
© www.soinside.com 2019 - 2024. All rights reserved.