在Quarto网站中,我如何添加填充整个页面但仅填充到主页的背景图像?

我有一个工作的解决方案,添加正确的背景,但它在整个网站上.在下面的示例中,我不希望报表页具有背景图像.它应该有一个纯白色的背景,导航栏和页脚.

可重复使用的例子.正在创建以下文件:

_quarto.yml

project:
  type: website

website:
  title: "Sunset Sea"
  navbar:
    background: transparent
    left:
      - text: Home
        href: "index.html"
      - text: Report
        href: "report.html"
  page-footer:
    border: false
    background: transparent
    foreground: DimGray
    left: Left content
    right: Right content

format:
  html:
    theme: "styles.css"

index.qmd

---
format: html
---

# Sunset Sea

Welcome to Sunset Sea.

report.qmd

---
title: "Report"
format: html
---

## Heading 1

This is a report

styles.css

/*-- scss:defaults --*/

body {
  background-image: url("https://images.pexels.com/photos/189349/pexels-photo-189349.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
  /*background-position: center center;*/
  /*background-attachment: fixed;*/
}

quarto preview

enter image description here

可能的解决方案是,仅在主页上的特定类的Body div之前或之后添加一个div,并以该类为目标.我不太确定该如何着手做那件事.

我试了include-before-body,但那不包括导航栏和页脚.

更新的_quarto.yml部分个

format:
  html:
    theme: "styles.css"
    include-before-body: before.html
    include-after: after.html

before.html

<div class="splash">

after.html

</div>

Update styles.css个*

.splash {
  background-image: url("https://images.pexels.com/photos/189349/pexels-photo-189349.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
}

enter image description here

Quarto 1.2.1

推荐答案

index.qmd个和Report.qmd将生成两个不同的网页.因此,如果您想要添加特定于index.html的任何样式,请直接在index.qmd个而不是style.css个中定义css样式(在style个标记内).

index.qmd

---
format: html
---

<style>
  body {
  background-image: url("https://images.pexels.com/photos/189349/pexels-photo-189349.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
}
  
</style>


# Sunset Sea

Welcome to Sunset Sea.

style.css

(不要在style.css中指定背景图片)

/*-- scss:defaults --*/


home page with background image


Report page with no background image


Html相关问答推荐

后续使用收件箱从网页表中提取值

我需要主页按钮出现在中间

如何使用css实现悬停时的动画zoom ?

禁用与行分开的边框折叠span

在iOS中调整HTML邮箱内容的大小

Css网格:两列,除非小于150px

旧文本淡出,但新文本不会淡入,而是突然出现

如何用css在右侧创建多个半圆

顶部有文字的图像的悬停效果

如何使活动选项卡背景作为父背景图像

为什么可滚动弹性项目需要 flex-basis: 0 ?

当我们在vue中使用截断大文本时如何显示标题属性?

Angular中如何向单选按钮添加验证

如何使用html css将图像显示为附加形状

BeautifulSoup用名称列表的findall无法找到另一个目标后面的目标

在shiny 的应用程序中使用图标功能时出错

什么没有 margin-right 和 width:100% 溢出子元素到左边?

是否可以使 huxtable 输出悬停?

如何在 svelte 中对静态 html 文件使用href=

flex-box 中的图像在 Chrome 和 Firefox 中看起来不同 - 如何使它们在 Firefox 中看起来像?