在多个 RMarkdown 文件中从 css 文件样式化 div
Styling div from css file in multiple RMarkdown files
我希望使用 css 文件在众多 RMarkdown 文件中设置 div 的样式。我在使用 css 文件样式 div.
的语法时遇到问题
在 rmarkdown 正文中使用样式标签有效(下面的代码示例)
---
title: "Untitled"
output:
html_document
---
<style>
div.positive {
background-color: #006B35;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
div.negative {
background-color: #C83C4D;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
</style>
<div class="positive">
Green background div
</div>
<div class="negative">
Red background div
</div>
当我删除 in body 样式并引用 css 文件时,div 没有样式(下面的代码示例)
CSS
.positive {
background-color: #006B35;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
.negative {
background-color: #C83C4D;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
RMarkdown
---
title: "Untitled"
output:
html_document:
css: "style.css"
---
<style>
div.positive {
}
div.negative {
}
</style>
<div class="positive">
Green background div
</div>
<div class="negative">
Red background div
</div>
使用单个 css 文件的目的是能够在单个文件中而不是在多个 rmarkdown 文件的主体中更改样式。
如有任何帮助,我们将不胜感激
YAML header 需要与逻辑组织相对应的缩进。你有
---
title: "Untitled"
output:
html_document:
css: "style.css"
---
但应该有
---
title: "Untitled"
output:
html_document:
css: "style.css"
---
css:
行有额外的缩进。
我希望使用 css 文件在众多 RMarkdown 文件中设置 div 的样式。我在使用 css 文件样式 div.
的语法时遇到问题在 rmarkdown 正文中使用样式标签有效(下面的代码示例)
---
title: "Untitled"
output:
html_document
---
<style>
div.positive {
background-color: #006B35;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
div.negative {
background-color: #C83C4D;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
</style>
<div class="positive">
Green background div
</div>
<div class="negative">
Red background div
</div>
当我删除 in body 样式并引用 css 文件时,div 没有样式(下面的代码示例)
CSS
.positive {
background-color: #006B35;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
.negative {
background-color: #C83C4D;
color: #ffffff; font-size:
16px; text-align:left;
vertical-align: middle;
padding: 0 10px;
80px
}
RMarkdown
---
title: "Untitled"
output:
html_document:
css: "style.css"
---
<style>
div.positive {
}
div.negative {
}
</style>
<div class="positive">
Green background div
</div>
<div class="negative">
Red background div
</div>
使用单个 css 文件的目的是能够在单个文件中而不是在多个 rmarkdown 文件的主体中更改样式。
如有任何帮助,我们将不胜感激
YAML header 需要与逻辑组织相对应的缩进。你有
---
title: "Untitled"
output:
html_document:
css: "style.css"
---
但应该有
---
title: "Untitled"
output:
html_document:
css: "style.css"
---
css:
行有额外的缩进。