如何覆盖标准的HTML标签?

发布于 2025-01-26 20:46:34 字数 811 浏览 3 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

二货你真萌 2025-02-02 20:46:34

TailWind CSS提供 @apply,这允许这样做。

h2 {
  @apply font-extrabold text-3xl my-5;
}

Tailwind CSS provides @apply that allows exactly this.

h2 {
  @apply font-extrabold text-3xl my-5;
}
南街女流氓 2025-02-02 20:46:34

可以通过定义 partials 来完成。

您需要在布局/partials中创建一个文件(实例布局/partials/tag.html)哪个内容是您最终要在html中拥有的内容,

<a href="/tags/{{ . }}" class="bg-gray-300 text-sm rounded-full p-1 px-2">{{ . }}</a>

这可以是然后用作{{部分“ tag.html”。 }}在您的代码中。

This can be done in Hugo by defining partials.

You need to create a file in layouts/partials (for instance layouts/partials/tag.html) which content is what you want to ultimately have in the HTML

<a href="/tags/{{ . }}" class="bg-gray-300 text-sm rounded-full p-1 px-2">{{ . }}</a>

This can be then used as {{ partial "tag.html" . }} in your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文