quarto

How to make a slide of two columns one static and other scrollable?


The below example shows two slides.

  1. A scrollable container that takes up the entire slide, with a scrollable image. This works.

  2. I want the full picture on the left side and on the right side the scrollable version. But this does not work.

How to make a slide of two columns one static and other scrollable?

---
format:  revealjs
---

## slide 1

This works!

::: {.scroll-container style="overflow-y: scroll; height: 500px;"}
![](https://images.unsplash.com/photo-1526512340740-9217d0159da9?q=80&w=1900&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D){fig-align="center" width="100%"}
:::

## slide 2

This does not work!

::: {layout-ncol=2}
![](https://images.unsplash.com/photo-1526512340740-9217d0159da9?q=80&w=1900&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D){fig-align="center" width="50%"}

::: {.scroll-container style="overflow-y: scroll; height: 500px;"}
![](https://images.unsplash.com/photo-1526512340740-9217d0159da9?q=80&w=1900&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D){fig-align="center" width="100%"}
:::
:::

Solution

  • This happens because the custom CSS gets overwritten by Quarto's layout defaults. You can keep it if you define a separate div within a .column, where the div has the needed properties:

    ---
    format:  revealjs
    ---
    
    ## slide 1
    
    This works!
    
    ::: {.scroll-container style="overflow-y: scroll; height: 500px;"}
    ![](https://images.unsplash.com/photo-1526512340740-9217d0159da9?q=80&w=1900&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D){fig-align="center" width="100%"}
    :::
    
    ## slide 2
    
    This also works!
    
    ::::: {layout-ncol=2}
    
    ![](https://images.unsplash.com/photo-1526512340740-9217d0159da9?q=80&w=1900&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D){fig-align="center" width="50%"}
    
    :::: {.column}
    ::: {.scroll-container style="overflow-y: scroll; height: 500px; position: sticky;"}
    ![](https://images.unsplash.com/photo-1526512340740-9217d0159da9?q=80&w=1900&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D){fig-align="center" width="100%"}
    :::
    ::::
    
    :::::