简体   繁体   English

Rmarkdown ioslides更改表头

[英]Rmarkdown ioslides changing table headers

I am trying to create my own table format for tables created using the ioslides_presentation output type of Rmarkdown with Rstudio Version 0.98.1028. 我正在尝试为使用Rosdown版本0.98.1028的ioslides_presentation输出类型创建的表创建自己的表格式。 Unfortunately I can't change the format of the table headers. 不幸的是我无法更改表头的格式。

This is the rmd file: 这是rmd文件:

---
title: "I can't change table headers with css"
author: "Blah Blah"
date: "August 27, 2014"
output: ioslides_presentation
css: slidetheme.css
---

## Ugly table

A            B           C
---------   --------    --------  
1           2            4
2           3            5

My css file: 我的css文件:

td, th {
  width: 4rem;
  height: 2rem;
  border: 1px solid #ccc;
  text-align: center;
}

td, tr {background:white; background-color:white; color: black;}

th {
  background: black;
  border-color: white;
}
body {
  padding: 1rem;
}

The table divisions respond to the css changes, but the header does not change. 表格分区响应css更改,但标题不会更改。 I have been back and forth with this, but can't figure out what is going on. 我一直在这里来回,但无法弄清楚发生了什么。 Does anyone know how to do this ? 有谁知道如何做到这一点 ?

Thanks in advance, Miguel 提前谢谢,米格尔

There are three things you'll need to do: 您需要做三件事:

First, change the YAML header so that the CSS is specified as a property of the ioslides_presentation format, like this: 首先,更改YAML标头,以便将CSS指定为ioslides_presentation格式的属性,如下所示:

output_format:
  ioslides_presentation:
    css: slidetheme.css

Second, in CSS the most specific rule wins, and the ioslides CSS (which you don't want to remove) has pretty specific rules for styling tables. 其次,在CSS中,最具体的规则获胜,而ioslides CSS(您不想删除)具有非常具体的样式表规则。 If you want to override them you'll need to make your rules even more specific or tag them with !important . 如果你想覆盖它们,你需要使你的规则更具体,或者用!important标记它们。 It's easiest to use the web inspector to see which rule is winning so you can adjust accordingly--click "Open in Browser" after render, then right-click -> Inspect Element (Chrome). 最简单的方法是使用Web检查器查看哪条规则获胜,以便您可以相应地进行调整 - 在渲染后单击“在浏览器中打开”,然后右键单击 - >检查元素(Chrome)。

Finally, since your CSS is combined, you'll need to do more than just add your own style, you'll also need to clear any CSS properties set by ioslides that you don't want applied. 最后,由于你的CSS被组合在一起,你需要做的不仅仅是添加你自己的风格,你还需要清除你不想应用的ioslides设置的任何CSS属性。

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

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