Shinyglide 包正是我所需要的,它使用輪播來分組單選按鈕,為用戶提供多種資料決議選擇。
但是,“下一步”(和“回傳”)按鈕占據了很大的空白區域。我想將按鈕與滑行行對齊(見底部圖片)。有誰知道如何做到這一點?有CSS技巧嗎?通讀 Glide 手冊,唯一的選擇是“top”和“bottom”。
如果無法移動 Next/Back 按鈕,則第二個選項是插入(有點多余的)文本行但與 Next/Back 按鈕保持一致,以至少掩蓋煩人的大空白。
這個實際的面板比這個例子有更多的資訊,所以我試圖使頁面盡可能干凈。
請參閱底部的圖片,它可以更好地解釋我正在嘗試做的事情。
可重現的例子:
library(dplyr)
library(DT)
library(shiny)
library(shinyglide)
ui <-
fluidPage(
fluidRow(div(style = "margin-top:15px"),
strong("Input choices shown in row below, click ′Next′ to see more choices:"),
column(12, glide(
height = "25",
controls_position = "top",
screen(
div(style = "margin-top:10px"),
wellPanel(
radioButtons(inputId = 'group1',
label = NULL,
choiceNames = c('By period','By MOA'),
choiceValues = c('Period','MOA'),
selected = 'Period',
inline = TRUE
),
style = "padding-top: 12px; padding-bottom: 0px;"
)
),
screen(
div(style = "margin-top:10px"),
wellPanel(
radioButtons(inputId = 'group2',
label = NULL,
choiceNames = c('Exclude CT','Include CT'),
choiceValues = c('Exclude','Include'),
selected = 'Exclude',
inline = TRUE
),
style = "padding-top: 12px; padding-bottom: 0px;"
)
)
)
)
),
DTOutput("plants")
)
server <- function(input, output, session) {
output$plants <- renderDT({iris %>% datatable(rownames = FALSE)})
}
shinyApp(ui, server)

uj5u.com熱心網友回復:
您可以使用帶有 的自定義控制元件元素custom_controls,然后將其懸停在右上角的顯示螢屏上,并將容器設定為絕對定位。為容器設定一個有限的寬度將確保后退按鈕不會飛得太遠。
這些方面的東西:
glide(custom_controls = div(class = "glide-controls", glideControls()), ...)
# Somewhere in the UI
tags$style(
".glide-controls { position: absolute; top: 18px; right: 15px; width: 160px; }"
)
只需確保還進行設定controls_position = "bottom",使控制元件懸停在螢屏內容上,而不是在其下方。
一個最小的示例應用程式:
library(shiny)
library(shinyglide)
ui <- fixedPage(
h3("Simple shinyglide app"),
tags$style(
".glide-controls { position: absolute; top: 18px; right: 15px; width: 160px; }"
),
glide(
custom_controls = div(class = "glide-controls", glideControls()),
screen(wellPanel(p("First screen."))),
screen(wellPanel(p("Second screen.")))
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/414692.html
標籤:
上一篇:拆分字串在R中保留空格
