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

发布于 2025-02-12 00:15:28 字数 716 浏览 0 评论 0原文

我想更改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?

I want to change the apperance of my dropdown tabset in R Markdown. For example, I want my dropdown to expand on hover and change the overall apperance of the box. Furthermore I want to change font, color, and text-alignment within the dropdown. I have tried a lot of different methods in my .css file without any success. See code and picture below.

This is the dropdown I want to customize

---
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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失退 2025-02-19 00:15:28

您需要在顶部的R代码中添加样式。CSS,也需要作为文件夹中的新文件。

R代码

---
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;
}

输出:

You need to add styles.css in your r code at the top, and also as a new file in your folder.

R Code

---
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 code (styles.css):

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

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

OUTPUT:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文