【发布时间】:2015-03-04 02:04:17
【问题描述】:
在 Google 上的闪亮组中寻找:
https://groups.google.com/forum/#!topic/shiny-discuss/J8C2CnFOTOM
我找到了一个解决方案,但是我只知道 HTML 的基础知识和一点 CSS。如何在我的代码中实现解决方案?
我需要将 gvisTable 放在中心。我把代码直接放到 htmlOutput 函数中,作为参数却报错:
**注意:这是我对代码所做的唯一更改。
tabPanel('Ikasa Adwords MotionChart',
br(),
htmlOutput("resumen",
tags$style(type="text/css",
HTML("#summary>div { margin: 0 auto; }")
)),
br(),
br(),
错误:
ERROR: argument is not interpretable as logical
原始ui.R:
library(shiny)
library(googleVis)
# Rely on the 'WorldPhones' dataset in the datasets
# package (which generally comes preloaded).
# Define the overall UI
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
br(),
br(),
br(),
titlePanel("Ikasa Adwords"),
# Generate a row with a sidebar
br(),
br(),
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
dateRangeInput("dates", label = h3("Date range"),
start = "2015-01-01", end = "2015-02-15")
),
mainPanel(
tabsetPanel(
tabPanel('Ika MotionChart',
br(),
htmlOutput("resumen",
tags$style(type="text/css",
HTML("#summary>div { margin: 0 auto; }")
)),
br(),
br(),
htmlOutput("motionchart")
)
)
)
)))
【问题讨论】:
-
猜猜
htmlOutput在这种情况下tags$style不接受第二个参数作为标签。您可以只提及内联真或假。同样在您的样式标签中,您说的是#summary,并且您的代码中没有ID为#summary的div。为了使其居中,您需要为元素提供宽度以及margin: 0 auto。