Я хочу создать html с помощью Rmarkdown. 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
![enter image description here](https://i.stack.imgur.com/B633t.png)
Однако мне бы хотелось, чтобы цвет вкладок секций 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>