问题描述
我认为这会很简单。除了正确的答案,我什么都试过了。
library(shiny)
library(shinythemes)
ui=fluidPage(
navbarPage("hi",theme=shinytheme("cerulean"),tabPanel("example",fluid = TRUE,icon = icon("globe-americas"),sidebarLayout(
sidebarPanel( p(style="text-align: center; ","sidepanel text")
),mainPanel(
fluidRow(column(width=12,p("first Box",style="font-size:125%;padding:12px;color:black; background-color:#fafafc"),div(strong("All I want is"),br(),p("for the text in red",span("to be on the right side of this container",style="align-text: right; color: red"),hr(),),column(width=12,p("third Box",style="font-size:125%;padding:12px;color:black; background-color:#fafafc"))
))
)))))
server=function(input,output,session) {}
shinyApp(ui=ui,server=server)
解决方法
在尝试模仿 HTML DOM 结构和元素类的同时使用 HTML 标签做到这一点,就像 Shiny 创建它们的方式一样。
一个 12 宽列中的两个 6 宽列元素将内容并排放置。我在每一列中都没有太大变化。
library(shiny)
library(shinythemes)
ui <- fluidPage(
navbarPage(
"hi",theme=shinytheme("cerulean"),tabPanel("example",fluid = TRUE,icon = icon("globe-americas"),sidebarLayout(
sidebarPanel(p(style="text-align: center; ","sidepanel text")),mainPanel(
fluidRow(
div("first box",style="font-size:125%;padding:12px;color:black; background-color:#fafafc",class="col-sm-12"
),column(12L,strong("All I want is")),div(
div(p("for the text in red",style="text-align:left; color:black"),class = "col-sm-6",style = "padding-left:0"),div(p("to be on the right side of this container",style="text-align:right; color:red"),style = "padding-right:0"),style="font-size:125%;padding:12px;background-color:#fafafc; margin-top:12px",class="col-sm-12")
),hr(),fluidRow(
div("third box",class="col-sm-12")
)
)
)
)))
server=function(input,output,session) {}
shinyApp(ui=ui,server=server)