如何在Bookdown中移除HTML输出里的图片边框?
移除Bookdown bs4_book模板中图片的边框
方法1:优化自定义CSS选择器(推荐)
bs4_book的默认主题样式优先级高于全局img选择器,需要用更具体的选择器覆盖原有样式:
将style.css中的代码替换为:
/* 针对book容器内的图片移除边框和阴影 */ .book .figure img { border: none; box-shadow: none; } /* 若figure容器本身带边框,一并移除 */ .book .figure { border: none; }
方法2:内联样式快速解决
直接在图片的代码块中添加out.extra参数,为图片设置内联样式:
```{r, fig.align='center', echo=FALSE, out.extra='style="border: none; box-shadow: none;"'} knitr::include_graphics('./images/Solar panel.jpg')
## 方法3:强制覆盖样式(慎用) 如果前两种方法无效,可使用`!important`强制覆盖所有冲突样式: ```css img, .img-fluid, .figure { border: none !important; box-shadow: none !important; }
重新编译Bookdown文档后,图片边框即可被移除。
内容的提问来源于stack exchange,提问作者Grant Coble-Neal
相关产品推荐
相关产品推荐

