简体   繁体   English

可以在kableExtra中更改悬停颜色吗?

[英]Is it possible to change the hover colour in kableExtra?

I regularly use the kable and kableExtra packages to create beautiful html tables via Rmarkdown. 我经常使用kablekableExtra包通过Rmarkdown创建漂亮的html表。

A client of mine recently requested the hover colour be yellow, rather than the current shade of grey. 我的一个客户最近要求悬停颜色为黄色,而不是当前的灰色。 Does anyone know if this is at all possible? 有人知道这是否完全可能吗?

An reproducible example: 可重现的示例:

require(knitr)
require(kableExtra)
kable(mtcars, "html") %>%
  kable_styling(bootstrap_options = c("striped", "hover"))

Of course it is. 当然是的。 Just add the following lines in your Rmd document: 只需在Rmd文档中添加以下行:

<style>
.table-hover > tbody > tr:hover { 
  background-color: #f4f442;
}
</style>

Just change the color value #f4f442 to whatever your client likes. 只需将颜色值#f4f442更改为客户喜欢的颜色即可。

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

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