html - 为不同部分设置 rmarkdown 选项卡颜色
问题描述
我想用 Rmarkdown 创建一个 html。html 应包含彩色标签。根据这个问题的答案,我尝试创建一个 rmarkdown 文件,我可以在其中设置不同选项卡的颜色。
这是一个最小的工作示例(降价):
---
title: "tab colors"
author: "cettt"
output:
html_document:
self_contained: no
---
<style>
.nav-pills>li>a {
color: red;
}
.nav-pills>li>a:hover, .nav-pills>li>a:focus, .nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus{
color: black;
background-color: red;
}
.nav-pills > li:nth-of-type(2)>a {
color: green;
}
.nav-pills > li:nth-of-type(2)>a:hover, .nav-pills > li:nth-of-type(2)>a:focus, .nav-pills > li:nth-of-type(2).active>a {
color: black;
background-color: green;
}
</style>
---
# {.tabset .tabset-fade .tabset-pills}
## red 1
## red 2
# {.tabset .tabset-fade .tabset-pills}
## green 1
## green 2
但是,我希望 red1 和 red2 部分的标签颜色为红色,而 green1 和 green2 部分的标签颜色为绿色。有人对此有什么建议吗?
编辑:
这是html的相关部分
<div id="section" class="section level1 tabset tabset-fade tabset-pills">
<h1></h1>
<div id="red-1" class="section level2">
<h2>red 1</h2>
</div>
<div id="red-2" class="section level2">
<h2>red 2</h2>
</div>
</div>
<div id="section-1" class="section level1 tabset tabset-fade tabset-pills">
<h1></h1>
<div id="green-1" class="section level2">
<h2>green 1</h2>
</div>
<div id="green-2" class="section level2">
<h2>green 2</h2>
</div>
</div>
解决方案
推荐阅读
- python - python lxml在某些情况下无法解析日语
- javascript - 如何在extjs中隐藏GridPanel的列
- java - Java Spring JPA - 字节 [] 到字符串
- c# - 我的测试用例没有执行,它开始执行但没有任何反应,并且显示未运行状态
- boost-test - CTest 和多测试二进制文件
- c# - TSQL 数组初始化和 LINQ Where on Array
- python - 使用 aiohttp 在线程中获取页面 - 得到 Future
连接到不同的循环 - java - 如何在spring-boot应用程序中的任何类/服务中获得身份验证
- python - 使用 python 和 boto3 在 aws 中获取配置的 S3 存储桶以获取详细的计费报告
- amazon-web-services - 使用 Ubuntu OVA 无法导入带有“ClientError: Unknown OS/Missing OS files”的 VM