r - How to align the text on the right side of the value box in R shiny?
问题描述
I am trying to write text in the value box. I want to align some text on the left side and some text on the right side in the same line. I tried this code:
library(shiny)
library(shinydashboard)
library(flexdashboard)
ui <- dashboardPage(skin = 'purple',
dashboardHeader(),
dashboardSidebar(),
dashboardBody(skin = 'purple',
fluidRow(
shinydashboard::valueBoxOutput("header", width = 12)
)))
server <- function(input, output) {
output$header <- shinydashboard::renderValueBox({
shinydashboard::valueBox(tags$p("Hello World!", style ="color : black"), "Hi!")
})
}
shinyApp(ui, server)
Using the above code, I got this:
But I want to display like this:
Hello on the left side and World! on the right side of the value box. If this is possible in the value box, how can I do it?
解决方案
If you want to have different styling on elements the best thing to do is to split them up in different tags.
In this case I would suggest span
since it is an inline tag. there are many different ways how o align on object with html and css. I believe the easiest is just to add float:right
to the second span tag.
output$header <- shinydashboard::renderValueBox({
shinydashboard::valueBox(tags$p(tags$span("Hello"),tags$span("World!", style = "float:right"), style ="color : black"), "Hi!")
})
推荐阅读
- python - 如何检查参数化构造函数参数的类型?
- ios - 出现键盘时 swift UITableView 向上滚动,但我看不到顶部单元格
- c# - 是否有根据您的代码(例如 C#)找到最佳数据库索引的程序?
- javascript - Webpack - 捆绑成单个文件或多个文件?
- python - 如何在仍然写入不同目录的同时压缩此代码?
- python - 无法导入json
- javascript - 从左到上移动侧栏
- java - WebClient 在 url 上抛出 404 - spring boot
- perforce - p4 unshelve 不带新添加的文件
- php - 如何在 Opencart 的网格视图中增加产品图像大小?