gadenbuie / xaringanExtra

:ferris_wheel: A playground of enhancements and extensions for xaringan slides.
https://pkg.garrickadenbuie.com/xaringanExtra
Other
445 stars 36 forks source link

use_banner conflict with css border-top #168

Closed jorgesinval closed 2 years ago

jorgesinval commented 2 years ago

The function use_banner does not place the top (right or left info) on the "true" top of the slide when using a custom css with the following code (i.e., border-top....):

.remark-slide-content {
  background-color: #FAFAFA;
  border-top: 80px solid #c70831;
  font-size: 20px;
  font-weight: 300;
  line-height: 1.5;
  padding: 1em 2em 1em 2em
}
xaringanExtra::use_banner(top_right = '<img src="https://pngimage.net/wp-content/uploads/2018/05/example-logo-png-1.png"  width="153"  alt="example">',
                          exclude = "title-slide")

image

gadenbuie commented 2 years ago

The problem is that the large top border effectively means that the top of the slide content area is where the white and red meet. You can use negative margins on the top banner to move it back into place. Here's something that would work in your custom CSS:

.xe-banner.top {
  margin-top: -60px;
}
gadenbuie commented 2 years ago

Also here's a complete minimal reprex for testing (you gave me everything I needed, but this wraps it up in one tiny xaringan document).

---
title: Issue 168
output:
  xaringan::moon_reader:
    seal: false
---

# Introduction

Text

```{r xaringanExtra-banner, echo = FALSE}
xaringanExtra::use_banner(
  top_right = '<img src="https://pngimage.net/wp-content/uploads/2018/05/example-logo-png-1.png"  width="153"  alt="example">',
  exclude = "title-slide"
)
.remark-slide-content {
  background-color: #FAFAFA;
  border-top: 80px solid #c70831;
  font-size: 20px;
  font-weight: 300;
  line-height: 1.5;
  padding: 1em 2em 1em 2em
}
.xe-banner.top {
  margin-top: -60px;
}
jorgesinval commented 2 years ago

Confirmed, working. Thank you!

jorgesinval commented 2 years ago

By the way, a small comment for those whiling to use the progress bar together with the banner. Use the use_progress_bar function instead of the "remarkish" solution (here). The latter will create an unstable behavior in the progress bar when the function use_banner is added to the slides.