查看“︁编程语言/tailwindcss”︁的源代码
来自康健生活
←
编程语言/tailwindcss
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 标题文本 == [https://tailwindcss.com/docs/detecting-classes-in-source-files#class-detection-in-depth 检测源文件中的类] == 主题 == [https://tailwindcss.com/docs/theme theme] 默认情况下在当前文件的文本域中,一定要在顶层引用 tailwindcss 之后主题才会生效,在文档中此处被称之为“<code>最终 CSS 输出中将仅生成使用的 CSS 变量</code>”,那么什么是<code>将仅生成使用</code>呢,很有歧义 {{hc|head=assets/module/theme.css|output=<syntaxhighlight lang="bash"> /* 生效 */ @import 'tailwindcss'; @theme { --ci-dark-bg: #121212; } </syntaxhighlight>}} 如果单独使用 <code>theme.css</code> 文件是一定不会生效的,但是不管几层文件引用,只要最上层存在 <code>@import 'tailwindcss';</code> 便会生效。 {{Double-columns|{{hc|head=assets/module/theme.css|output=<syntaxhighlight lang="bash"> /* 不生效 */ @theme { --ci-dark-bg: #121212; } </syntaxhighlight>}}|{{hc|head=assets/index.css|output=<syntaxhighlight lang="bash"> /* 生效 */ @import 'tailwindcss'; @import './module/theme.css'; </syntaxhighlight>}}}} 但是如果在 js 文件中引用分开便不会生效 {{Double-columns|{{hc|head=assets/module/theme.css|output=<syntaxhighlight lang="bash"> /* 不生效 */ @theme { --ci-dark-bg: #121212; } </syntaxhighlight>}}|{{hc|head=src/main.ts|output=<syntaxhighlight lang="bash"> /* 不生效 */ import './assets/tailwind.css' import './assets/index.css' </syntaxhighlight>}}}} 也就说我们可以理解一个 css 文件在 js 中的引用,便形成一个独立的上下文,在相同上下文中 css 的多层引用嵌套不会影响主题的生成,但是如果拆分开分别通过 js 的 impoert 引用就会形成上下文隔离,主题就会因为内部计算 <code>将仅生成使用</code> 时判断零使用而生成空主题。 这个时候可以通过 [https://tailwindcss.com/docs/theme#generating-all-css-variables static] 标识突破这种隔离,但是不利于 tree shaking。 <syntaxhighlight lang="css"> @theme static {}</syntaxhighlight> == preflight == 在构建过程中去掉 <code>layer(base)</code> 以便添加自定义的基础样式。tailwindcss 的 [https://tailwindcss.com/docs/preflight preflight] 基础样式是基于 [https://github.com/sindresorhus/modern-normalize modern-normalize],而我常用的是 [https://github.com/necolas/normalize.css normalize.css],两者之间仍有差别。 <syntaxhighlight lang="css"> @layer theme, base, components, utilities; @import 'tailwindcss/theme.css' layer(theme); @import 'tailwindcss/utilities.css' layer(utilities);</syntaxhighlight> == 暗黑模式 == [https://tailwindcss.com/docs/dark-mode 暗黑模式]如果只是页面中元素的样式改变,直接参阅 tailwindcss 文档就可以。但如果关联了第三方应用(eq: codemirror)就需要借助一些持久化函数 <syntaxhighlight lang="css"> @custom-variant dark (&:where(.dark, .dark *)); /* @custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *)); */ </syntaxhighlight>
此页面嵌入的页面:
模板:Double-columns
(
查看源代码
)
模板:Double-columns/style.css
(
查看源代码
)
模板:Hc
(
查看源代码
)
模板:Hc/style.css
(
查看源代码
)
返回
编程语言/tailwindcss
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。