unocss css框架

(1)安装unocss

npm install unocss;

 (2)入口文件

import "unocss";

(3)配置uno.config.ts

import presetWeapp from 'unocss-preset-weapp';
import { extractorAttributify, transformerClass } from 'unocss-preset-weapp/transformer';
import { defineConfig, presetIcons } from 'unocss';

const { presetWeappAttributify, transformerAttributify } = extractorAttributify();

export default defineConfig({
  presets: [
    // https://github.com/MellowCo/unocss-preset-weapp
    presetWeapp({
      isH5: process.env.TARO_ENV === 'h5',
      platform: 'taro',
      taroWebpack: 'webpack5',
      designWidth: 375,
      deviceRatio: {
        640: 2.34 / 2,
        750: 1,
        828: 1.81 / 2,
        375: 2 / 1
      }
    }) as any,
    presetWeappAttributify(),
    presetIcons()
  ],
  shortcuts: [
    {
      'border-b': 'border-0 !border-b-1px border-b-solid border-b-#e9e9e9',
      'border-t': 'border-0 !border-t-1px border-t-solid border-t-#e9e9e9',
      'border-l': 'border-0 !border-l-1px border-l-solid border-l-#e9e9e9',
      'border-r': 'border-0 !border-r-1px border-r-solid border-r-#e9e9e9',
      tag: 'min-w-30px h-20px w-auto text-12px text-#619A4B center bg-#E8F4E4 rounded-99px px-8px',
      'tag-warn': 'min-w-30px h-20px w-auto text-12px text-#F54B45 center bg-#FFE2E1 rounded-99px px-8px',
      'tag-gray': 'min-w-30px h-20px w-auto text-12px text-black center bg-#F7F7F7 rounded-99px px-8px',
      'tag-orange': 'min-w-30px h-20px w-auto text-12px text-#EF6918 center bg-#FDECD7 rounded-99px px-8px',
      center: 'flex justify-center items-center'
    }
  ],

  transformers: [
    // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
    transformerAttributify() as any,

    // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
    transformerClass() as any
  ],
  theme: {
    color: {
      bg: 'rgba(22, 33, 255, 1)'
    }
  }
});

(4)使用

<div class="w-100px"></div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值