coloring tabs in rmarkdown

邮差的信 提交于 2020-06-01 12:40:34

问题


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

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.

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.

Can anyone help me out?


回答1:


You can work with the nth() child CSS selector https://www.w3schools.com/cssref/sel_nth-child.asp

In your case add this within the <style> tag:

.nav-pills>li:nth-child(2) {
    background: green;
 }


来源:https://stackoverflow.com/questions/55276670/coloring-tabs-in-rmarkdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!