考虑以下rmarkdown文件:
---
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来更改所有标签的颜色。 但是,我希望第二个标签(绿色的标签)具有不同的颜色。
我做了一些尝试,并尝试通过手动添加一些html标签(如
)为第二部分创建一个不同的html类。<a_green role="tab" data-toggle="tab" href="#tab-green" aria-controls="tab-green">tab green</a_green>
但这并没有达到预期的效果。
有人可以帮我吗?
答案 0 :(得分:1)
您可以使用nth()
子CSS选择器https://www.w3schools.com/cssref/sel_nth-child.asp
在您的情况下,请在<style>
标签内添加此标签:
.nav-pills>li:nth-child(2) {
background: green;
}