css - 如何将 css 样式元素添加到 Rmd 闪亮的 renderImage?
问题描述
我正在努力将 css 样式元素添加到我闪亮的 renderImage 代码中。我尝试了通过 tag$link 使用 css 源文件以及通过 tag$style 使用直接 css 代码的各种选项。
我已经尝试了 tag$link 和 tag$style 选项(在我的示例代码中)(1)在 renderImage 代码之外(2)在 renderImage 代码内,在列表包装器之外(3)在 renderImage 代码内, 在列表包装器内部
我得到以下两个错误之一:错误 1:“闭包”类型的对象不是子集错误 2:找不到对象“centerImage”
在我的本地机器上使用我的 logo5.png 图像,没有额外的 css - 它可以工作。在我的本地机器上使用我的 logo5.png 图像,以及额外的 css - 它不起作用。
请注意,我在 renderImage 之前将“1”、dir() 和“2”留在了代码中以跟踪执行情况。
有人可以帮忙吗?
(要在 Rstudio 中运行,请将 rrr`` 更改为 4 个位置的 3 个反引号)
(我的在线图片网址是http://www.richpat.com/wp-content/uploads/2019/04/logov5.png)
---
title: 'Shiny Dev with Logo'
output:
flexdashboard::flex_dashboard:
theme: united
orientation: columns
source_code: embed
runtime: shiny
---
rrr``{r setup, include=FALSE} #CORRECT THIS WHEN RUNNING
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(flexdashboard,quietly=TRUE, verbose=FALSE)
library(shiny,quietly=TRUE, verbose=FALSE)
library(plotly,quietly=TRUE, verbose=FALSE)
rrr`` #CORRECT THIS WHEN RUNNING
Corporate
=======================================================================
Column
-----------------------------------------------------------------------
### Logo
rrr``{r} #CORRECT THIS WHEN RUNNING
(1)
dir()
#tag$head(tags$link(rel = "stylesheet", type = "text/css", href = "BRstyle.css"))
#tag$head(tag$style("centerImage {text-align:center;}"))
(2)
renderImage({
rfilename=normalizePath("logov5.png")
list(src=rfilename, contentType = "image/png", alt = "logo5", class=centerImage)
}, deleteFile = FALSE)
rrr`` #CORRECT THIS WHEN RUNNING
Background
=======================================================================
Column
-----------------------------------------------------------------------
### Purpose
ad valorem libram
解决方案
好的 - 所以我找到了答案。简单是路线...
我没有在闪亮的renderImage中这样做,而是学到了很多关于闪亮和flexdashboard以及markdown如何协同工作的知识!
我使用 img html 标记作为带有直接显示标记的降价部分的一部分
<img src="http://www.richpat.com/wp-content/uploads/2019/04/logov5.png"
alt="Markdown Monster icon"
style="ftext-align:center; display: center;" />
我删除了完整的闪亮renderImage r-code部分
作为奖励 - 只是为了展示更多我学到的东西,这是我修改后的 yaml
title: 'Br F A'
output:
flexdashboard::flex_dashboard:
logo: logov5s.png
theme: readable
css: BRstyle.css
navbar:
- { title: "About", href: "http://www.richpat.com", align: left }
source_code: embed
orientation: columns
runtime: shiny
推荐阅读
- html - 即使使用相同的 css,保证金也会更大
- azure-data-factory-2 - 我们可以在自定义任务中设置 ADF 参数值或链接的服务连接字符串吗
- python - 用folium显示TomTom地图
- algorithm - 如何降低移动点凸包的复杂度?
- c# - 如何在mvc中设置gridview
- javascript - 使用节点在服务器上进行图像优化
- java - 无法获取令牌(OAUTH2、Spring、Kotlin)
- c# - AI 第三人称控制器敌人腿不动,但角色和航路点与敌人一起移动。Unity3d
- r - R闪亮for循环中的进度条
- angular - 如何以编程方式(使用 Javascript)使用新的 Chrome 版本(从 v69 开始)设置窄窗口大小?