css - 在 Flexdashboard 中更改激活页面的颜色

标签 css r r-markdown flexdashboard

我的 flexdashboard 有问题。我想将具有多个页面的仪表板的导航栏颜色更改为灰色(我成功了),并将事件/选定页面或我悬停的页面的颜色更改为黄色(我不能这样做)。这是我使用的代码。我不确定如何找到可以更改的导航栏元素的名称,以便更改导航栏。

---
title: "Example"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: fill
---
<style>                     
.navbar {
  background-color:grey;
  hover-color:yellow;
}

</style> 

背景变成灰色(就像我希望的那样),但是我悬停在上面的选定页面或页面保持蓝色。有谁知道如何处理这个问题?非常感谢!

最佳答案

这会很棘手,因为您必须覆盖所有控制悬停颜色的 css 元素。一个简单的解决方法是更改​​主题:

---
title: "Example"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: fill
    theme: <enter theme name>
---

主题可以在 flexdashboard site 上找到.

我也需要做一些类似的事情,我想我发现了大部分需要改变的元素:

<style>
.navbar {
  background-color:grey;
}

.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus {
    background-color: yellow;
    color: white;
}
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
  color: white;
  background-color: yellow;
}
.navbar-inverse .navbar-toggle:hover,
.navbar-inverse .navbar-toggle:focus {
  background-color: yellow;
}
.navbar-inverse .navbar-collapse,
.navbar-inverse .navbar-form {
  border-color: yellow;
}
</style>

您可以在此处找到需要更改的导航栏元素:https://github.com/thomaspark/bootswatch/blob/v3.3.5/cosmo/bootstrap.css#L4643-L4744

关于css - 在 Flexdashboard 中更改激活页面的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58064754/

相关文章:

r - 如何在 R 的摘要输出中查看隐藏在 "Other"下的元素?

r - 如何更改 Donut ggplot 图中的plot.background?

html - 如何创建如图所示的曲面 block ?

html - 导航栏中 anchor 中的点

javascript - 时间轴 JScript 在 IExplorer 中不起作用

css - 当用户将鼠标悬停在列表项上时,如何将光标变为手形?

r - 如何使用 R 在一个面板中绘制贝叶斯先验分布和后验分布?

regex - 使用gsub删除多个空格和尾部空格

css - Rmarkdown : Indentation of TOC items in HTML output

R:如何使用 RMarkdown ioslides 制作二级缩进的要点?