你如何在 RShiny 的 UI 中左右对齐部分文本?
How do you left and right align parts of a text in RShiny's UI?
看到 运行 这个小程序后的红色文字。我想右对齐那部分。
我认为这会很简单。除了正确答案,我什么都试过了。
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"),
br(),
style="font-size:125%;padding:12px;color:black; background-color:#fafafc"),
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"),
class = "col-sm-6", 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",
style="font-size:125%;padding:12px;color:black; background-color:#fafafc",
class="col-sm-12")
)
)
)
)))
server=function(input, output,session) {}
shinyApp(ui=ui, server=server)
看到 运行 这个小程序后的红色文字。我想右对齐那部分。
我认为这会很简单。除了正确答案,我什么都试过了。
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"),
br(),
style="font-size:125%;padding:12px;color:black; background-color:#fafafc"),
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"),
class = "col-sm-6", 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",
style="font-size:125%;padding:12px;color:black; background-color:#fafafc",
class="col-sm-12")
)
)
)
)))
server=function(input, output,session) {}
shinyApp(ui=ui, server=server)