[英]Remove all Table CSS from `bookdown::gitbook`
I'm toying bookdown
to write some documentation for pixiedust
that I feel might be a bit too lengthy for a vignette. 我正在bookdown
,为pixiedust
编写一些文档,我觉得这可能对于一个小插图来说有点过于冗长。 I like the layout of bookdown::gitbook
, but that, unfortunately, comes with its own table styling that is problematic for me. 我喜欢bookdown::gitbook
的布局,但不幸的是,它带有自己的桌面样式,这对我来说是个问题。 Since pixiedust
is all about styling tables, it is a little challenging to show what pixiedust
has done (or hasn't done) with the default gitbook styling. 由于pixiedust
是关于样式表,因此使用默认的gitbook样式显示pixiedust
已完成(或尚未完成)的内容有点困难。
I've tried clearing the CSS with guidance from 我已尝试在指导下清除CSS
R bookdown gitbook - how to override table style R bookdown gitbook - 如何覆盖表格样式
and 和
How to change the code padding effect of gitbook? 如何更改gitbook的代码填充效果?
I've had no luck with putting the css code in a css file in my root directory and putting the file name in the css
YAML tag. 我把css代码放在我的根目录下的css文件中,并将文件名放在css
YAML标记中,我没有运气。 I've had no luck with making a styles
subdirectory. 我在制作一个styles
子目录时没有运气。 And the version below hasn't worked either. 以下版本也没有用。
---
title: "Sample Book"
output:
bookdown::gitbook:
config:
toc:
collapse: section
scroll_highlight: true
before: null
after: null
theme: null
css: ".book .book-body .page-wrapper .page-inner section.normal table td, .book .book-body .page-wrapper .page-inner section.normal table th { border-left: none; border-right: none; }"
---
```{r, warning = FALSE, message = FALSE, echo = FALSE}
library(pixiedust)
dust(head(mtcars))
```
Everything I've tried produces a table that looks like 我尝试过的所有东西都会产生一张看起来像的桌子
What I'd like is something that looks like 我想要的是看起来像什么
At the moment, my root directory is empty save for the index.Rmd
file with the code given above. 目前,我的根目录为空,除了index.Rmd
文件,上面给出了代码。
I'm using R 3.2.2 and bookdown
0.3 我正在使用R 3.2.2和bookdown
0.3
Probably not the best solution but you can remove some of the styling by replacing it with some "default" CSS in your markdown above the chunk displaying the table: 可能不是最好的解决方案,但你可以通过在显示表格的块上方的markdown中用一些“默认”CSS替换它来删除一些样式:
```{r results="asis", echo=FALSE}
cat("
<style>
.book .book-body .page-wrapper .page-inner section.normal table
{
width:auto;
}
.book .book-body .page-wrapper .page-inner section.normal table td,
.book .book-body .page-wrapper .page-inner section.normal table th,
.book .book-body .page-wrapper .page-inner section.normal table tr
{
padding:0;
border:0;
background-color:#fff;
}
</style>
")
```
You can look for CSS resets and add more if you need to. 您可以查找CSS重置并在需要时添加更多。
You could define a css reset class. 您可以定义一个css重置类。 Either with a bunch of properties you care about or try the new all
attribute if internet explorer support is not important to you. 要么关注一堆属性,要么尝试使用新的all
属性,如果Internet Explorer支持对您不重要的话。
.reset{
all: initial;
}
Or 要么
.reset{
border: initial;
padding: initial;
...
}
Then apply to the table: 然后申请表:
<table class="reset">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.