【问题标题】:In Quarto how do I write inline CSS在 Quarto 中,我如何编写内联 CSS
【发布时间】:2023-02-09 17:48:30
【问题描述】:

我想给句子中的一个词上色,该句子以四开本格式呈现为 HTML。在 R Markdown 中,我只想添加一个 css 标签,但我不知道如何在四开本中做到这一点。 quarto documentation 说可以编写内联 css 但没有示例。有一个显示 R Markdown 示例的超链接:

```{css, echo=FALSE}
body {
  color: red;
}
```

当我这样做时,quarto 将代码显示为代码块并且不使用 CSS。

如何将 CSS 代码块添加到四开本文档中?

【问题讨论】:

    标签: css r quarto


    【解决方案1】:

    只需用[]包围你想要设置样式的单词,然后将样式写在{}中,就像这样

    the color is [red]{style="color: red;"}
    

    所以red这个词会是红色的。

    要添加更多详细信息,

    ---
    title: "inline style"
    format: html
    ---
    
    ## inline style in Quarto
    
    We can apply styles to a sentence or a word 
    by creating spans using `[]` to surround the
    sentence or word that we want to style and 
    use `{}` to define the style that we want to 
    apply. For example,
    
    The color of this word is [red]{style="color: red;"}. 
    And [this line has a yellow background]{style="background-color: yellow"}.
    
    

    渲染后,我们得到这个,

    【讨论】:

    • 非常感谢@shafee。太棒了。您应该在 GitHub 上创建 quarto 文档并添加此示例。
    • @itsMeInMiami,它已经在那里了,我想是this is it
    • @shafee 我们如何添加元标记,以便当我们在聊天(whatsapp 或其他)中共享 HTML 文件时,显示如下 SO example。我特别想以文本形式共享一个独立的 html 报告,但想在图像和文本中显示一些信息,而不仅仅是文件名
    • @user5249203,能否提出一个单独的问题,以便其他人和我一起正确回答:)?
    猜你喜欢
    • 2012-02-28
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    相关资源
    最近更新 更多