有没有办法用HTML后端更改涂鸦中的字体颜色?
(更具体地说,我想在图书馆的手册中放置一个大的红色警告标签。
事实证明,您可以直接在涂鸦中执行此操作,而无需使用后端依赖解决方案。诀窍是使用具有 color-property
的样式。
使用elem
设置样式(如此处所示),您可以创建一个colorize
函数来设置文本的颜色。
(define (colorize #:color c . content)
(elem #:style (style #f (list (color-property c)))
content))
然后你可以像这样使用它:
@colorize[#:color "red"]{WARNING}
您还可以起诉background-color-property
设置文本的背景。
正如 Alexis 提到的,您可以使用与级联样式表 (CSS) 配对的class
,如下所示:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<!-- that's to link our styles to the webpage. -->
</head>
<body>
<!-- some time later... -->
<p class = "example">test</p>
<!-- the rest of the website -->
在mystyle.css
:
.example{ /* select all tags with the "example" class */
color: #FF0000; /* change font color using hex value */
background-color: #552222; /* change background color using hex value */
}
现在,如果我们能够使用多个文件,那就太好了。 但是,如果您想将所有内容都放在一个文件中,我们可以在<style>
标签中发送相同的信息:
<head>
<!-- no need to link our styles, since they're embedded in the webpage. -->
</head>
<body>
<style>
.example{ /* select all tags with the "example" class */
color: #FF0000; /* change font color using hex value */
background-color: #552222; /* change background color using hex value */
}
</style>
<!-- some time later... -->
<p class = "example">test</p>
<!-- the rest of the website -->
还有另一种嵌入它的方法,但你不应该使用它。 曾。 这始终是正确的方法。
如果你需要更多来自CSS方面的内容,请参阅 http://www.w3schools.com/css/css_examples.asp。
手动创建包含 attributes
属性的 style
结构似乎有效:
#lang scribble/base
@(require scribble/core
scribble/html-properties)
@para[#:style (style #f `(,(attributes '([style . "color:blue;"]))))]{blue text}