vue.js - Tailwind CSS : The `focus:border-2` class does not exist, 但 `focus:rotate-2` 确实

标签 vue.js tailwind-css postcss

我在 Vue 3 中使用 Tailwind CSS,看起来我无法更改焦点上输入元素的边框宽度。我的index.css我有:

form-input {
    @apply block appearance-none mb-1 bg-white w-full border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:border-blue-500 focus:border-2 disabled:bg-gray-200
}

我收到错误: focus:border-2 类不存在,但 focus:rotate-2 存在。如果您确定 focus:border-2 存在,请确保在 Tailwind CSS 看到您的 CSS 之前正确处理所有 @import 语句,如 @ apply 只能用于同一 CSS 树中的类。

我做错了什么吗? 包.json "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17",

最佳答案

这个答案对我有帮助:

https://github.com/tailwindlabs/tailwindcss/discussions/1889#discussioncomment-23241

It's important to understand that @apply will not work for inlining pseudo-class or responsive variants of another utility. Instead, apply the plain version of that utility into the appropriate pseudo-selector or a new media query:

    /* Won't work: */
    .btn {
      @apply block bg-red-500;
      @apply hover:bg-blue-500;
      @apply md:inline-block;
    }

    /* Do this instead: */
    .btn {
      @apply block bg-red-500;
    }
    .btn:hover {
      @apply bg-blue-500;
    }
    @screen md {
      .btn {
        @apply inline-block;
      }
    }

关于vue.js - Tailwind CSS : The `focus:border-2` class does not exist, 但 `focus:rotate-2` 确实,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70663389/

相关文章:

html - 如何在设定时间后停止 tailwindcss 动画

reactjs - PurgeCSS 在 next.js 中删除 Tailwind 字体

javascript - Vue.js:转换动画在点击时不起作用

javascript - v-for 之后的 Vue 指令

typescript - 为什么即使我能够获得对我尝试滚动到的元素的引用,scrollIntoView 在 Vue 3 中不起作用

reactjs - TailwindCSS : How can I fix a header & footer to the screen while keeping scrollable content in between?

html - 如何修复 tailwindcss-cli 抛出 TypeError : Object. fromEntries is not a function?

css - 使用 Angular 8 + Tailwind.css + LESS 进行缓慢的 Webpack 编译

storybook - 如何在汇总包中最好地包含 scss 文件中引用的 Assets (图像和字体)

unit-testing - 在 Vue Test Utils 中模拟退格键