Rstudio 0.98.1028 add background image only to title slide

牧云@^-^@ 提交于 2019-12-29 06:25:25

问题


I am attempting to create a R Presentation (.Rpres) using RStudio 0.98.1028 with a different background image on the title slide and another background image on the rest of the slides. I am able to place a custom background (foo.png) by creating a css file with this in it:

    body {
      background-image: url(foo.png);
      background-position: center center;
      background-attachment: fixed;
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }

I was able to turn off the default color scheme on the title slide and make the color black with this:

.section .reveal .state-background {
    background: transparent;}

.section .reveal h1,
.section .reveal p {
    color: black;



}

To get foo1.png into the title slide, Other posts (Adding an image to title slide using slidify) I have seen suggest adding this to the css:

.title-slide {
     background-image: url(foo1.png);
   }

Which does not insert foo1.png. However, foo.png stays on all the slides (including the title slide). How do I get foo1.png on my title slide?


回答1:


You're 99% of the way there. Just one or two more tweaks and you'll have it. You may consider adding the following to ensure your slides are using the separate css file with something like the following added to your title slide.

Intro
======
author: Clever Name
css: css-file.css

You then can overwrite the background of the title slide by including the following between <style> </style> tags at the very top of your .Rpres file before your intro slide, or in your separate css file.

<style>
/* Your other css */

.section .reveal .state-background {
    background: url(foo1.png);
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
</style>

You're really close. Just change your title-slide { /* do stuff */ } to .section .reveal .state-background { /* do stuff */ }



来源:https://stackoverflow.com/questions/28916359/rstudio-0-98-1028-add-background-image-only-to-title-slide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!