rmarkdown 中的着色选项卡
考虑以下 rmarkdown 文件:
consider the following rmarkdown file:
---
title: "tab colors"
output:
html_document:
self_contained: no
---
<style>
.nav>li>a {
position: relative;
display: block;
padding: 10px 15px;
color: #990000;
}
.nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus {
color: #ffffff;
background-color: #990000;
}
</style>
#{.tabset .tabset-fade .tabset-pills}
##Tab red
Tab red
##Tab green
Tab green
我可以通过在开始时添加一些 css 来更改所有选项卡的颜色.但是,我希望第二个标签(标签绿色)具有不同的颜色.
I was able to change the color of all tabs by adding some css in the beginning. However, I would like the second tab (tab green) to have a different color.
我进行了一些实验,并尝试通过手动添加一些 html 标记来为第二部分创建一个不同的 html 类
I experimented a little bit and tried to create a different html-class for the second section by manually adding some html tag like
<a_green role="tab" data-toggle="tab" href="#tab-green" aria-controls="tab-green">tab green</a_green>
但这并没有达到预期的效果.
But this did not had the desired effect.
有人可以帮我吗?
您可以使用 nth()
子 CSS 选择器 https://www.w3schools.com/cssref/sel_nth-child.asp
You can work with the nth()
child CSS selector https://www.w3schools.com/cssref/sel_nth-child.asp
在您的情况下,在 <style>
标签中添加:
In your case add this within the <style>
tag:
.nav-pills>li:nth-child(2) {
background: green;
}