You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Quarto中定义新提示框(Callout)的最佳实现方法咨询

定义Quarto全新自定义提示框的最佳实现方式

要在Quarto中创建完全独立的全新提示框,且不影响默认提示框样式,最佳方式是自定义专属CSS类,结合Quarto的callout基础结构实现,具体步骤如下:

1. 编写自定义SCSS样式

在你的custom.scss文件中,定义专属的提示框类(比如.callout-custom),设置独立的样式属性,避免覆盖默认callout的全局样式:

/*-- scss:rules --*/
/* 全新自定义提示框的基础样式 */
.callout-custom {
  background-color: #e6f7ff; /* 自定义背景色 */
  border-left: 4px solid #1890ff; /* 左侧边框颜色 */
  color: #0050b3; /* 文本颜色 */
}

/* 自定义提示框的图标样式 */
.callout-custom .callout-icon {
  color: #1890ff; /* 图标颜色匹配主题 */
}

/* 可选:自定义提示框标题样式 */
.callout-custom .callout-title {
  font-weight: bold;
  font-size: 1.1em;
  color: #1890ff;
}

2. 在Quarto文档中使用自定义提示框

在文档中通过:::语法,同时引用Quarto的基础.callout类和你的自定义类,即可渲染出独立的提示框:

---
format: 
  html: 
    theme:
      - custom.scss
---

::: {.callout .callout-custom}
这是一个完全自定义的提示框,样式仅作用于当前容器,不会影响默认提示框
:::

::: {.callout-tip}
这是默认的提示框,样式不受自定义规则影响
:::

3. 进阶:添加自定义标题与图标

如果需要给自定义提示框设置专属标题和图标,可以在容器内添加标题元素,或者通过CSS伪元素自定义图标:

/* 自定义提示框的图标(使用伪元素) */
.callout-custom .callout-icon::before {
  content: "💡"; /* 替换为你需要的图标 */
}

使用时可指定标题:

::: {.callout .callout-custom}
### 💡 自定义提示标题
这是带自定义标题和图标的提示框内容
:::

这种方式的核心优势是完全隔离默认样式,你可以根据需求创建任意数量的自定义提示框类型,每个类型的样式独立可控。

内容的提问来源于stack exchange,提问作者boshek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 14:40:15