V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
heroisuseless
V2EX  ›  问与答

有没有类似于 tailwind 但是是组合类型的 css 库?例如将 display: flex; flex-direction: row; align-items: center; 合为 flex-h-center 这样

  •  
  •   heroisuseless · 1 天前 · 478 次点击

    我发现我平时使用 tailwind 其实大多数也是在做重复工作,例如写个居中对齐就是 flex items-center ,于是我想有没有组合类型的 css 库,将常用的多个 css 组合合并为一个类,例如 flex-v-center 从而达到比 tailwind 还少写代码的目的

    tailwind 是原子类型的 css 库,例如:flex justify-center items-center bootstrap 是组件类型的 css 库 我现在想找在这两者之间的库,即组合类型的 css 库,例如将 display: flex; flex-direction: row; align-items: center; 合为 flex-h-center 这样

    8 条回复    2024-09-20 12:05:28 +08:00
    ZZITE
        1
    ZZITE  
       1 天前
    不考虑下 tailwind 的 addUtilities 吗,自己注册一些常用的样式组合
    addUtilities({
    .flex-h-center {
    'display': 'flex',
    'flex-direction': 'row',
    'align-items': 'center'
    }
    })
    koor
        2
    koor  
       1 天前
    用 unocss ,可以配置 shortcuts ,完美符合你的需求
    waiaan
        3
    waiaan  
       1 天前
    @koor
    unocss 和 elementui 的样式冲突是怎么解决的?就是 button 的样式。
    defaw
        4
    defaw  
       1 天前
    https://tailwindcss.com/docs/reusing-styles
    这功能自带的,如此操作你就获得了可以直接使用的 btn-primary
    @layer components {
    .btn-primary {
    @apply py-2 px-5 bg-violet-500 text-white font-semibold rounded-full shadow-md hover:bg-violet-700 focus:outline-none focus:ring focus:ring-violet-400 focus:ring-opacity-75;
    }
    }
    heroisuseless
        5
    heroisuseless  
    OP
       1 天前
    @ZZITE 我希望有一套良好设计的组合 css ,而不是自己设计这个组合 css 叫什么,是即开即用型而不是自己设计,这套组合 css 可以不用很全,仅包括最常用的组合 css 即可,可以与 tailwind 搭配,但是这套组合 css 是预设好的,设计精良的
    heroisuseless
        6
    heroisuseless  
    OP
       1 天前
    @defaw 不是组件型 css 而是组合型 css ,按我的想法是在组件型 css 与原子型 css 之间的组合型 css ,我现在就是好奇有没有这种设计精良的组合型 css
    antony98
        7
    antony98  
       1 天前
    直接给 tailwind 提 PR 就有了,不做伸手党,也为开源做贡献
    unclemcz
        8
    unclemcz  
       1 天前 via Android
    你要的可能是 https://www.ripple-ui.com/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1034 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 23:13 · PVG 07:13 · LAX 16:13 · JFK 19:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.