gpt4 book ai didi

html - 在 uioutput 显示下方的新行中显示文本[ Shiny ]

转载 作者:行者123 更新时间:2023-11-28 15:53:36 26 4
gpt4 key购买 nike

uiOutput('myTable')其次是 p("Here is some text....")将文本放在 uioutput 旁边显示,但我喜欢从页面左侧开始在新行中打印文本。添加br()只是添加相当于屏幕宽度的空白空间,因此,文本从新行开始,而不是从页面左侧开始。有趣的是,添加任何控件小部件,例如 dateInput在新行中显示小部件。就我而言,uioutput输入来自 map [ purrr ].我结合了map输出和HTML("<br>")通过list ,但无解。这是可重现的代码:

library(shiny)
ui <- fluidPage(
tabPanel("Test",
numericInput("samsize","specify sample size",4,1,52),
uiOutput('myTable'),
#dateInput("date", label = "Today's Date")
#br(""),
p("Here is some text...")
))

server <- function(input, output) {
data <- reactive({
alphabets <- c(letters,LETTERS)
Index <- seq(1,length(alphabets),1)
names(Index) <- alphabets

# Notice I don't put the vector in a one row matrix as in you example
sample(Index,input$samsize)
})

library(purrr) # map is a nice alternative to lapply
output$myTable <- renderUI(map(names(data()),~div(strong(.),
div(data()[.]),
style="float:left;padding:10px 20px;")))
}

shinyApp(ui, server)

这是屏幕截图。正如所见,这是一些文本uioutput 旁边显示,我想在显示下方换行 enter image description here

最佳答案

使用 div 样式 float:left 后,需要清除 float ,例如使用 clear:left:

ui <- fluidPage(
tabPanel("Test",
numericInput("samsize","specify sample size",4,1,52),
uiOutput('myTable'),
div("Here is some text...", style="clear:left;"),
dateInput("date", label = "Today's Date")
))

Result using clear:left

您将找到有关 float div 的更多信息 here

关于html - 在 uioutput 显示下方的新行中显示文本[ Shiny ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41470353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com