繁体   English   中英

如何在 R Markdown 中自定义和设置 tabset.dropdown 样式?

[英]How can I customize and style tabset.dropdown in R Markdown?

我想在 R Markdown 中更改我的下拉选项卡集的外观。 例如,我希望我的下拉菜单在悬停时展开并更改框的整体外观。 此外,我想在下拉列表中更改字体、颜色和文本对齐方式。 我在我的 .css 文件中尝试了很多不同的方法,但都没有成功。 请参阅下面的代码和图片。

这是我要自定义的下拉菜单

---
output:
  html_document:
    theme: paper
    highlight: tango
    number_sections: false
    toc: false
    toc_float: false
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Title {.tabset .tabset-fade .tabset-pills}

### Subject1 {.tabset .tabset-dropdown}

#### How can i customize this?

#### How can i customize this?

### Subject2 {.tabset .tabset-dropdown}

#### How can i customize this?

#### How can i customize this?

您需要在顶部的 r 代码中添加 styles.css,也需要在文件夹中添加新文件。

代码

---
output:
  html_document:
    theme: paper
    highlight: tango
    number_sections: false
    toc: false
    toc_float: false
    css: styles.css
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Title {.tabset .tabset-fade .tabset-pills}

### Subject1 {.tabset .tabset-dropdown}

#### How can i customize this?

#### How can i customize this?

### Subject2 {.tabset .tabset-dropdown}

#### How can i customize this?

#### How can i customize this?

CSS 代码(styles.css):

.nav-tabs > li.active:nth-child(1) > a {
  background-color: #E8C120;
}

.nav-tabs > li > a {
  background-color: #5882A6;
  color: red;
}

输出: 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM