简体   繁体   English

css background-image在Rmd slidify中不起作用

[英]css background-image does not work in Rmd slidify

All, 所有,

I cannot understand why the image is not displayed in the background of my document, generated within RStudio (via the knitr button, to generate a slidy html document). 我不明白为什么图像中没有我的文件,内产生的背景显示RStudio (通过knitr按钮,生成一个slidy html文件)。

here is my reproducible example: 这是我的可复制示例:

test.Rmd test.Rmd

---
title: "test"
output: 
  slidy_presentation:
    css: testcustom.css
    font_adjustment: -3
---

## Introduction {#intro}

### Hello World! 

This works: background-color: #6495ed;  
This does not work: background-image: url(pic/Presentation.jpg);

testcustom.css testcustom.css

#intro {
    background-image: url(pic/Presentation.png);
    background-color: #6495ed;
}

image is the following: http://displaynote.com/wp-content/uploads/2015/02/Presentation.jpg , located in pic/Presentation.jpg 图像如下: http : //displaynote.com/wp-content/uploads/2015/02/Presentation.jpg ,位于pic / Presentation.jpg中

How can I fix this problem? 我该如何解决这个问题? It neither works in IE nor in Chrome . 它既不能在IE也不在Chrome

Many thanks for your help! 非常感谢您的帮助!

I think it's actually working, but your image is so large that it's offscreen! 我认为它确实可以正常工作,但是您的图像太大,无法显示在屏幕上! Try this content for testcustom.css to scale the JPG file so it fits the screen: 尝试使用此内容来使testcustom.css缩放JPG文件,使其适合屏幕大小:

#intro {
    background-image: url(pic/Presentation.jpg);
    background-color: #6495ed;
    background-size: 100% 100%;
}

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

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