• tailwindcss 一览表


    在这里插入图片描述
    文章首发于 tailwindcss一览表

    引入 tailwindcss 的目的是减少编写 css ,下面列出的是 tailwindcss 一览表:

    间距

    默认情况下,Tailwind 包括一个丰富和全面的数字间隔比例。这些值是成比例的,所以 16 是 8 的两倍。一个间距单位等于 0.25rem,在通用浏览器中默认为 4px。

    会应用 padding/margin/top/left/right/bottom/width/height/lineHeight/,p-1 = padding: 4px;/p-1 = padding: 0.25rem;

    前缀

    输入前缀会有代码提示,代码提示中包含具体内容。

    前缀含义
    box-设置box-sizing
    float-设置浮动float
    clear-清楚浮动clear
    object-用于控制可替换元素的内容如何调整大小及在其容器中的位置object-fit/object-position
    overflow-如何处理超出容器的内容overflow
    overscroll-用于控制浏览器到达滚动区域边界时的行为overscroll-behavior
    z-用于设置z-index
    flex/flex-flex布局flex/flex-direction/flex-wrap/flex-grow/flex-shrink
    orderflex和grid的排序order
    justify-用于设置justify-content/justify-items/justify-self
    content-用于设置align-content
    items-用于设置align-items
    self-用于设置align-self
    grid-grid布局grid-template-columns/grid-column/grid-template-rows/grid-auto-flow
    row-元素的大小和放置方式grid-row
    auto-控制隐式创建的网格行/列的大小grid-auto-rows/grid-auto-columns
    gap-grid和flexbox items间隔gap/row-gap/column-gap
    place-用于同时控制内容如何在水平和垂直方向上对齐place-content/place-items/place-self
    p-内边距padding
    m-外边距margin
    w-元素宽度width
    min-w-最小宽度min-width
    max-w-最小宽度max-width
    h-元素高度height
    min-h-最小高度min-height
    max-h-最小高度max-height
    font-字体序列font-family/字体粗细font-weight
    text-字体大小、行高、对齐、颜色、透明度font-size/line-height/text-align/color
    leading-行高line-height
    tracking-字母间距letter-spacing
    align-设置vertical-align
    whitespace-设置white-space
    break-文本换行overflow-wrap/word-break
    placeholder-占位文本颜色及透明度
    list-列表项标记类型list-style-type/list-style-position
    bg-背景相关background-attachment/background-clip/background-color/background-origin/background-position/background-repeat/background-size/background-image
    rounded-设置border-radius
    border-设置边框颜色、厚度、透明度、样式、表格边框border-width/border-color/border-style/border-collapse
    divide-设置分割线颜色、厚度、透明度、样式
    ring-设置分割线颜色、厚度、透明度、偏移厚度、偏移颜色box-shadow
    shadow-盒阴影
    opacity-不透明度opacity
    table-表格布局table-layout
    transition-过渡属性transition-property/transition-timing-function/transition-duration
    duration-过渡持续时间transition-duration
    ease-过渡计时函数transition-timing-function
    delay-过渡延迟transition-delay
    animate-动画animation
    transform-变换transform
    origin-变换原点transform-origin
    scale-缩放
    rotate-旋转
    translate-平移
    skew-倾斜
    pointer-指向事件pointer-events
    resize/resize-大小调整resize
    select-用户选择user-select
    cursor-光标效果cursor
    outline-轮廓outline/outline-offset

    特殊的,无共同前缀

    Top / Right / Bottom / Left

    使用 {top|right|bottom|left|inset}-0 功能类,将绝对定位的元素锚定在最近定位的父元素的任何边缘上。

    可见性

    ClassProperties
    visiblevisibility: visible;
    invisiblevisibility: hidden;

    定位

    ClassProperties
    staticposition: static;
    fixedposition: fixed;
    absoluteposition: absolute;
    relativeposition: relative;
    stickyposition: sticky;

    元素显示类型

    ClassProperties
    blockdisplay: block;
    inline-blockdisplay: inline-block;
    inlinedisplay: inline;
    flexdisplay: flex;
    inline-flexdisplay: inline-flex;
    tabledisplay: table;
    inline-tabledisplay: inline-table;
    table-captiondisplay: table-caption;
    table-celldisplay: table-cell;
    table-columndisplay: table-column;
    table-column-groupdisplay: table-column-group;
    table-footer-groupdisplay: table-footer-group;
    table-header-groupdisplay: table-header-group;
    table-row-groupdisplay: table-row-group;
    table-rowdisplay: table-row;
    flow-rootdisplay: flow-root;
    griddisplay: grid;
    inline-griddisplay: inline-grid;
    contentsdisplay: contents;
    list-itemdisplay: list-item;
    hiddendisplay: none;

    文本装饰

    ClassProperties
    underlinetext-decoration: underline;
    line-throughtext-decoration: line-through;
    no-underlinetext-decoration: none;

    文本转换

    ClassProperties
    uppercasetext-transform: uppercase;
    lowercasetext-transform: lowercase;
    capitalizetext-transform: capitalize;
    normal-casetext-transform: none;

    文本溢出

    ClassProperties
    truncateoverflow: hidden;text-overflow: ellipsis;white-space: nowrap;
    overflow-ellipsistext-overflow: ellipsis;
    overflow-cliptext-overflow: clip;

    字体样式

    ClassProperties
    italicfont-style: italic;
    not-italicfont-style: normal;

    悬停、焦点和其它状态

    下面列出几个常用的

    Hover

    添加 hover: 前缀,以在 hover 状态时应用一个功能类。

    <button class="bg-red-500 hover:bg-red-700 ...">
      Hover me
    button>
    
    • 1
    • 2
    • 3

    Focus

    添加 focus: 前缀,以在 focus 状态时应用一个功能类。

    <input class="focus:ring-2 focus:ring-blue-600 ...">
    
    • 1

    Active

    添加 active: 前缀,以在元素处于 active 状态时应用某个功能。

    <button class="bg-green-500 active:bg-green-700 ...">
      Click me
    button>
    
    • 1
    • 2
    • 3

    Disabled

    添加 disabled: 前缀,以便当一个元素被禁用时才应用功能类。

    <button class="disabled:opacity-50 ..." disabled>
      Submit
    button>
    
    • 1
    • 2
    • 3

    Visited

    添加 visited: 前缀,以便当一个链接被访问后才应用功能类。

    <a href="#" class="text-blue-600 visited:text-purple-600 ...">Linka>
    
    • 1

    First-child

    添加 first: 前缀,以仅当元素是父元素的第一个子元素时才应用功能类。当使用某种循环生成元素时,最为有用。

    <div v-for="item in items" class="transform first:rotate-45 ...">
      {{ item }}
    div>
    
    • 1
    • 2
    • 3

    Last-child

    添加 last: 前缀,在仅当元素是父元素的最后一个子元素时才应用功能类。当使用某种循环生成元素时,最为有用。

    <div v-for="item in items" class="transform last:rotate-45 ...">
      {{ item }}
    div>
    
    • 1
    • 2
    • 3

    Odd-child

    添加 odd: 前缀使得仅在元素是父级奇数子元素的时候才应用功能类。当使用某种循环生成元素时,最为有用。

    <div v-for="item in items" class="transform odd:rotate-45 ...">
      {{ item }}
    div>
    
    • 1
    • 2
    • 3

    Even-child

    添加 even: 前缀使得仅在元素是父级偶数子元素的时候才应用功能类。当使用某种循环生成元素时,最为有用。

    <div v-for="item in items" class="transform even:rotate-45 ...">
      {{ item }}
    div>
    
    • 1
    • 2
    • 3

    个人配置

    为了使用方便,个人增加如下配置 tailwind.config.js

    /** @type {import('tailwindcss').Config} */
    module.exports = {
      purge: ["./public/index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"], // 生产优化,删除未使用的CSS
      content: [],
      theme: {
        extend: {
          fontSize: {
            // 增加字体配置
            // text-12 = font-size: 12px;
            // text-sm = font-size: 24px;line-height: 21px;
            12: "12px",
            14: "14px",
            16: "16px",
            18: "18px",
            20: "20px",
            24: "24px",
            30: "30px",
            sm: ["14px", "21px"],
            md: ["16px", "24px"],
            lg: ["20px", "30px"],
            xl: ["24px", "36px"],
          },
          lineHeight: {
            // 增加行高配置
            // leading-12 = line-height: 12px;
            12: "12px",
            14: "14px",
            16: "16px",
            18: "18px",
            20: "20px",
            21: "21px",
            24: "24px",
            27: "27px",
            30: "30px",
            36: "36px",
            45: "45px",
          },
          borderRadius: {
            // 增加圆角配置
            // rounded-2 = border-radius: 2px;
            0: "0px",
            2: "2px",
            4: "4px",
            6: "6px",
            8: "8px",
            10: "10px",
            12: "12px",
            14: "14px",
            16: "16px",
            18: "18px",
            20: "20px",
            22: "22px",
            24: "24px",
            26: "26px",
            28: "28px",
            30: "30px",
          },
        },
      },
       // 使用变体新增状态类
      variants: {
        extend: {
          backgroundColor: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          backgroundOpacity: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          borderColor: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          borderOpacity: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          boxShadow: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          opacity: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          outline: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          textColor: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          textOpacity: ['active', 'disabled', 'visited', 'first', 'last', 'odd', 'even'],
          margin: ['first', 'last', 'odd', 'even'],
          padding: ['first', 'last', 'odd', 'even']
        }
      },
      plugins: [],
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77

    tailwind.css :

    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    
    .clearfix:before,
    .clearfix:after {
      display: table;
      content: "";
    }
    
    .clearfix:after {
      clear: both;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • 相关阅读:
    【C++】-C++11中的知识点(上)--右值引用,列表初始化,声明
    基础的语法
    【智能优化算法】基于移动阻尼波算法求解单目标优化问题附matlab代码
    芸鹰蓬飞:抖店服务分怎么快速升分?
    数据的存储--Redis缓存存储
    企业微信的自动下班是什么意思?
    Vue框架中的面试相关问题
    javax.net.ssl.SSLException: Connection reset
    axios post 请求发送url 键值对参数
    NFT Insider112:The Sandbox聘请Apple高管担任其首席内容官,YGG 将在菲律宾举办Web3游戏峰会
  • 原文地址:https://blog.csdn.net/fxss5201/article/details/127842754