我无法在所有幻灯片的左上角创建标题,包括标题幻灯片.我用format: revealjs来做幻灯片.

当使用纯revealjs,没有Quarto时,我能够在div class="reveal"中嵌入自定义divheader.但是,我不能在Quarto框架内这样做,因为在HTML内呈现任何定制条目都会移除定制条目.

有什么建议吗?请多多关照!

Note:我知道页脚选项,而且我已经在使用页脚做其他事情了,现在我需要页眉.


在纯Revel.JS中,我使用了嵌入在index.html中的以下代码:

<div class="reveal">
    <div class="header">
        <section data-markdown="slides/header.md"></section>
    </div>
    <!-- slides in markdown here-->
</div>

我在我的slides/header.md美元里有以下几点:

Custom header text appears on top left corner of all slides..

为了显示在所有幻灯片的左上角,我在reveal.scss中嵌入了以下css:

.reveal .header {
    position: absolute;
    top: 1em;
    left: 1em;
    font-size: 0.7em;
}

我不能在Quarto中复制它,因为一旦我呈现.qmd文件,html文件就被修改了.我也不知道这个"头"是否可以嵌入到.qmd文件的标题参数中.

目前,我在.qmd文件中使用以下代码生成页脚:

format:
    revealjs:
        ...
        footer: "custom footer text"

推荐答案

您可以编写脚本代码,将定制div插入到html文件中类为reveal的div中,然后使用include-after-body YAML键在Quarto文件中引用该html文件.

quarto_revealjs.qmd

---
title: "Untitled"
format: revealjs
css: header.css
include-after-body: header_text.html
---


## Quarto

Quarto enables you to weave together content and executable code into a
finished presentation. To learn more about Quarto presentations see
<https://quarto.org/docs/presentations/>.

## Bullets

When you click the **Render** button a document will be generated that
includes:

-   Content authored with markdown
-   Output from executable code

header_text.html

在这个文件中,我们为要放在类为reveal的div中的div编写html代码,然后使用js代码将该div元素作为类为reveal的div的第一个子元素插入.

<div class="header">
    <section>
      Custom header text appears on top left corner of all slides..
    </section>
</div>

<script>
  function add_header() {
    let header = document.querySelector("div.header");
    let reveal = document.querySelector(".reveal");
    reveal.insertBefore(header, reveal.firstChild);
  }
  
  window.onload = add_header();
</script>

header.css

.reveal .header {
    position: absolute;
    top: 0.3em;
    left: 1em;
    font-size: 0.5em;
    color: gray;
}

.reveal .slides {
  margin-top: 0.5em;
}

title page with a header


next page with that header in top left corner

Html相关问答推荐

关于角内按钮范围的混乱

注册组件不显示当我导航到注册站点

悬停时跳转的内容

我无法从带Angular 的Bootstrap 5中的表单中获取数据

SVG的动态CSS

根据Tailwind CSS中的子计数而非子宽度进行对齐,并水平对齐

:invalid Select 器的惰性判断

jquery向单词中的一组字母添加跨度

为什么当我按第三个按钮时,前两个按钮会跳动?

带有数据 URI 的音频在 Chrome 中失败

对齐列表项内的文本,使其不在元素装饰下

如何在Rmarkdown中添加千位分隔符?

在HTML请求中添加源URL

在随机图像下对齐文本

暗模式转换器

Primeng浮动标签溢出管理

如何使用 :before 在 CSS 中为列表增加计数器

如何自定义具有白色透明背景的光标图像?

是否可以使用纯 css 创建具有斜角效果的锯齿形边缘?