例如,创建一个带有 Tailwind 样式的自定义按钮: /* 在你的 CSS 文件中 */@layercomponents{.btn{@applypx-4py-2bg-blue-500text-white font-semibold rounded-lg;}.btn-danger{@applypx-4py-2bg-red-500text-white font-semibold rounded-lg;}} 然后在 HTML 中使用自定义按钮类: 实例 <buttonclass="...
This method uses the @tailwind directive in a CSS file to style different parts of Tailwind CSS. The @tailwind base directive helps you set basic styles for elements like the HTML and body tags. Here, we will use the @layer directive to add a default font color to the base layer. Synta...
font-size: 2rem; } } @layer components { btn-blue { @apply bg-blue-500 px-4 py-2 rounded-xl font-bold hover:bg-blue-700; } } @config:用于指定 Tailwind 在编译该 CSS 文件时应使用的配置文件 @config "./tailwind.input.config.js"; b. 函数 函数用于访问 Tailwind 中的特定值,构建后会...
Use thetext-[<value>]syntaxto set thetext colorbased on a completely custom value: <pclass="text-[#50d71e]..."> <!-- ... --> </p> For CSS variables, you can also use thetext-(<custom-property>)syntax: <pclass="text-(--my-color)..."> ...
Tailwind CSS - Font Variant Numeric Tailwind CSS - Letter Spacing Tailwind CSS - Line Clamp Tailwind CSS - Line Height Tailwind CSS - List Style Image Tailwind CSS - List Style Position Tailwind CSS - List Style Type Tailwind CSS - Text Align Tailwind CSS - Text Color Tailwind CSS - Text ...
<h1class="text-3xl font-bold text-center mt-4">Welcome to Tailwind CSS!</h1> </body> </html> 创建CSS: npx tailwindcss -i ./src/input.css -o ./src/output.css --watch 现在,当你在浏览器中打开 index.html 时,你应该会看到一个粗体的大标题,上面写着Welcome to Tailwind CSS!
说明:使用Tailwind CSS可省略写繁琐的css代码,通过用class快速布局,如下图页面全是class,很少会写css代码。 例子: 创建variable.css文件,代码如下可定义样式变量: :root{--color-G100:#FBFBFB;--color-G150:#F6F6F8;--color-G200:#F0F1F2;--color-G300:#E6E6E8;--color-G400:#D1D2D4;--color-G500:...
font-size: 14px; border-radius: 2px; color: #fff; border-color: #ff4d4f; background: #ff4d4f; text-shadow: 0 -1px 0 rgb(0 0 0 / 12%); box-shadow: 0 2px #0000000b; } 以上是最常见、最常规的写法,被称作 Semantic CSS(语义化 CSS)规范。在这种规范下,追求关注点分离,让结构与样...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Font Color Example</title> <!-- 引入Tailwind CSS --> <link hre...
经过一段时间的使用,tailwindcss 方案已经能够很流畅的使用了,没有想象中的不适感,整体设计风格很统一,熟练之后能够很流畅地写出复杂样式,和传统的css、less相比,明显的感受是上下文切换变少了,和css-in-js相比,敲键盘次数变少了,原以为只是一个 css 工具集,但它的强大超出我的预期,一些复杂的联动效果也能轻松完...