本文介绍了在uioutput显示屏下面的新行中显示文本[闪亮]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

uiOutput('myTable')后跟 p(这里是一些文本....)将文本放在 uioutput 显示旁边,但我喜欢以从页面左侧开始的新行打印文本。添加 br()只是添加相当于屏幕宽度的空白空间,因此,文本从新行开始,但不从页面的左侧开始。有趣的是,添加任何控件小部件,例如 dateInput 会在新行中显示该小部件。在我的情况下, uioutput 输入来自地图 [ purrr ]。我通过列表输出和 HTML(< br>) code>,但没有解决方案。这里是可重现的代码:

uiOutput('myTable') followed by p("Here is some text....") puts the text next to uioutput display, but I like to print the text in a new line starting from left side of the page. Adding br() is simply adding empty space equivalent to screen width, therefore, text starts from a new line but not from from the left side of the page. Interestingly, adding any control widget, e.g., dateInput displays the widget in a new line. In my case, uioutput input comes from map [ package purrr]. I combined map output and HTML("<br>") via list, but no solution. Here is reproducible code:

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 显示旁边,我想在显示屏下面的新行中显示

Here is screen shot. As it is seen, Here is some text is next to uioutput display, which I want to be in a new line below the display

推荐答案

使用 div 您可以使用 float:left 清除浮动,例如使用清除:left

After using div with style float:left, you need to clear the floating, for example with 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")
  ))

您将找到有关浮动的更多信息 div

You will find more info about floating div here

这篇关于在uioutput显示屏下面的新行中显示文本[闪亮]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 08:35