v3.0.18我在 pug 文件中使用 Tailwind CSS 任意值时遇到问题。我遵循了这个答案,但它没有解决问题。
这是我的哈巴狗文件:
.container.mx-auto.flex.items-center.space-x-1
.box.p-8.bg-yellow-800.text-white(class="w-1/2")
h1.font-bold(class='text-2xl') It's normal
.box.p-8.bg-yellow-800.text-white(class="w-[50%]")
h1.font-bold(class='text-\[40px\]') It Doesn't Work
Run Code Online (Sandbox Code Playgroud)
那么,在 pug 中应用 Tailwind CSS 任意值的正确方法是什么?
我正在使用 Tailwind v3。
我有一个自定义背景颜色,通过 javascript 以内联样式应用:
<div style="background-color: RANDOM_GENERATED_COLOR" />
Run Code Online (Sandbox Code Playgroud)
但是在移动断点中,我希望它忽略这个背景颜色,我想要没有背景。所以我所做的是添加!bg-transparent,使用“!” 修饰符我让它覆盖内联样式:
<div style="background-color: RANDOM_GENERATED_COLOR" class="!bg-transparent" />
Run Code Online (Sandbox Code Playgroud)
但是,我不希望在所有其他断点sm及以上断点处覆盖内联样式。
是否可以!bg-transparent仅针对移动断点?
我创建了一个 Angular 库,其样式使用 Tailwind 进行设计。然后将其推送到 NPM,然后导入到新项目中,但 css 未得到应用。我在 tailwind.config.ts 中引用了节点模块路径:
content: [
"./src/**/*.{html,ts}",
'./node_modules/components-name/**/*.{html,js,ts}'
],
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
如果我将 Tailwind 直接应用到新应用程序,则它可以正常工作,但它不适用于导入的库。
Tailwindcss 文档(v3)讨论得inset box shadow非常简短,以至于我找不到将自定义插入框阴影应用到元素的方法。也shadow-inner-[0px_-2px_4px_rgba(0,0,0,0.6)]不起作用。只有默认值shadow-inner适用于该元素。有没有办法将自定义阴影内部应用到元素?或者如何在tailwind.config.js文件中定义自定义文件?
我正在开发一个使用EJS作为模板引擎的Node.js Express项目。我正在 Intellij Ultimate Edition 上开发这个。Intellij 的 tailwind css 插件已安装。我使用 tailwindcss v3 作为我的 css 框架。我遵循了他们的入门指南,并使用 Tailwind CLI 作为我的安装方法。
tailwind.config.js
module.exports = {
mode: 'jit',
content: ['./views/*.ejs'],
theme: {
extend: {},
},
plugins: [],
};
Run Code Online (Sandbox Code Playgroud)
我正在像这样构建 css:
npx tailwindcss -i source.css -o public/stylesheets/style.css --watch
源文件.css
@tailwind base;
@tailwind components;
@tailwind utilities;
Run Code Online (Sandbox Code Playgroud)
所以一切都工作正常,没有问题,但是我在 IDE 中是一个没有错误/警告的人(阅读 OCD),并且 IDE 中显示的错误/警告困扰着我,我想知道如何修复它或者如果它本来就是这样,那么如何抑制呢?
我添加了屏幕截图以供参考。如果需要更多信息来调试,请告诉我,我很乐意提供。
我正在尝试设置 Tailwind 3,但我收到了下一个警告。
No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.
Run Code Online (Sandbox Code Playgroud)
这是我的项目结构
|_public :
|_index.html ,
|_output.css // this css file generated after i run the command | npx tailwindcss -i ./src/input.css -o ./public/output.css --watch
|_src
|_input.css
Run Code Online (Sandbox Code Playgroud)
tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
}
Run Code Online (Sandbox Code Playgroud) 如果这是一个明显的问题,我很抱歉,这是我第一次尝试构建组件库。
我正在使用 Tailwind CSS 3 构建 React 组件库。当我使用 Storybook 运行组件时,它们会按预期显示。但是,当我与 Rollup 捆绑时,会应用类名称,但 CSS 不包含在构建中。
这是我的tailwind.config.js文件:
module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {},
},
plugins: [],
};
Run Code Online (Sandbox Code Playgroud)
我的rollup.config.js文件:
import babel from 'rollup-plugin-babel';
import external from 'rollup-plugin-peer-deps-external';
import resolve from '@rollup/plugin-node-resolve';
import postcss from 'rollup-plugin-postcss';
import { terser } from 'rollup-plugin-terser';
const packageJson = require('./package.json');
export default [
{
input: 'src/index.js',
output: [
{
file: packageJson.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [
postcss({
config: …Run Code Online (Sandbox Code Playgroud) 我安装了 prettier-plugin-tailwindcss,当我使用 运行 Prettier 时,它成功地对 Tailwind 类进行了排序npx prettier --write index.html。但是,当我在 VScode 中点击“保存”时,prettier-plugin-tailwindcss 不会按预期对 Tailwind 类进行排序。
我正在关注本教程和本文档。正如您所看到的,我正确设置了开发依赖项,并且.prettierrc.json在项目中有一个。``
我期望当我点击“保存”时,它会自动按预期工作,即对顺风类进行排序,但该插件仅在使用运行 prettier 时才有效npx prettier --write index.html
我尝试过的事情:
我将保存格式设置为 true 并设置路径,但没有解决问题。
除了斜体和粗体之外,降价不起作用。我发现这个问题是由 Tailwind CSS 引起的,因为它处理文本大小和其他样式的方式。如果我在 my 中注释掉index.css导入(定义了 Tailwind 的指令)index.jsx,则所有 Markdown 类型(如标题、代码等)都可以正常工作。
新闻.jsx
import ReactMarkdown from 'react-markdown';
import { useState } from 'react';
function News() {
const [markdown, setMarkdown] = useState('# I am heading');
return (
<div>
<textarea value={markdown} onChange={e => setMarkdown(e.target.value)} />
<ReactMarkdown>{markdown}</ReactMarkdown>
</div>
);
}
export default News;
Run Code Online (Sandbox Code Playgroud)
index.css
import ReactMarkdown from 'react-markdown';
import { useState } from 'react';
function News() {
const [markdown, setMarkdown] = useState('# I am heading');
return (
<div>
<textarea value={markdown} onChange={e …Run Code Online (Sandbox Code Playgroud) 我的设置一切正常,但我有一个问题:我的自定义字体未加载到 Storybook 中。
(我的主要问题是关于缺少的CSS变量,请到底部查看它。我只是发布所有代码以供参考。)
部分目录结构:
这是我在“app/(site)/layout.tsx”中使用 Next 修复本地字体的地方:
布局.tsx
import "../styles/globals.css"
import type { Metadata } from "next"
import localFont from "@next/font/local"
import Header from "@/app/components/Header"
import Footer from "@/app/components/Footer"
import { getCachedClient } from "@/sanity/lib/getClient"
import SiteConfigQuery from "@/sanity/queries/site-config/siteConfigQuery"
import { MobileDrawer } from "../components/MobileDrawer"
const tTFirs = localFont({
src: [
{
path: "../../public/fonts/TypeType - TT Firs Regular.otf",
weight: "300"
},
{
path: "../../public/fonts/TypeType - TT Firs Medium.otf",
weight: "400"
},
{
path: "../../public/fonts/TypeType - TT Firs Medium …Run Code Online (Sandbox Code Playgroud) tailwind-css ×10
css ×2
reactjs ×2
fonts ×1
next.js ×1
plugins ×1
postcss ×1
prettier ×1
pug ×1
rollupjs ×1
storybook ×1
tailwind-3 ×1
tailwind-ui ×1