如何覆盖标准的HTML标签?
我正在 tailwind CSS (我走了),在阅读Hugo和Tailwind文档后,一个点还不清楚:如何覆盖标准标签?
例如:H1
。想象一下,我希望它应用于IT类.text-bold
和.text-xl
(这些是尾管类)。正确的方法是什么:
- 将SCSS用于
@Extend
这些类?
h1 {
@extend .text-xl, .font-bold ;
}
→不起作用,无法识别这些类:
Error: Error building site: TOCSS: failed to transform "styleScssSource.scss" (text/x-scss): SCSS processing failed: file "stdin", line 2, col 23: The target selector was not found.
Use "@extend .font-bold !optional" to avoid this error.
使用一些雨果机制替换为fly
< h1>
,用< h1 class =“ text-xl font-font-bold “>
? (我不知道这是否可以完成)或其他?
I am writing a web site in Hugo and Tailwind CSS (and learning as I go) and one point is not clear after reading both Hugo and tailwind documentation: how to override standard tags?
As an example: h1
. Imagine I would like it to apply to it classes .text-bold
and .text-xl
(these are Tailwind classes). What is the correct approach:
- using SCSS to
@extend
these classes?
h1 {
@extend .text-xl, .font-bold ;
}
→ does not work, the classes are not recognized:
Error: Error building site: TOCSS: failed to transform "styleScssSource.scss" (text/x-scss): SCSS processing failed: file "stdin", line 2, col 23: The target selector was not found.
Use "@extend .font-bold !optional" to avoid this error.
using some Hugo mechanism to replace on the fly
<h1>
with<h1 class="text-xl font-bold">
? (I do not know if this can be done)or something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TailWind CSS提供
@apply
,这允许这样做。
Tailwind CSS provides
@apply
that allows exactly this.可以通过定义 partials 来完成。
您需要在
布局/partials
中创建一个文件(实例布局/partials/tag.html
)哪个内容是您最终要在html中拥有的内容,这可以是然后用作
{{部分“ tag.html”。 }}
在您的代码中。This can be done in Hugo by defining partials.
You need to create a file in
layouts/partials
(for instancelayouts/partials/tag.html
) which content is what you want to ultimately have in the HTMLThis can be then used as
{{ partial "tag.html" . }}
in your code.