Unocss 类名基操, tailwindcss 类名

这里只列出 unocss 的可实现类名,tailwindcss 可以拿去试试用

1. 父元素移入,子元素改样式

html 复制代码
<!-- 必须是 group 类名 -->
<div class="group">
	<div class="group-hover:color-red">Text</div>
</div>

2. 按钮反色移入

html 复制代码
 <div
    class="size-min bg-gradient-to-r from-blue from-50% to-red to-50% bg-[size:200%] bg-[100%] hover:bg-[0%] transition-all duration-1000"
  >
   <button   
     class="w-100 h-10 z-1 color-transparent bg-clip-text bg-gradient-to-r from-red from-50% to-blue to-50% bg-[size:200%] bg-[100%] hover:bg-[0%] transition-all duration-1000"
  >
    A Button
  </button>
</div>

3. background-image、background-size、background-position

html 复制代码
<div class="bg-[url(xx.png)] bg-[size:10%] bg-[position:10%]"></div>

4. 渐变色背景

html 复制代码
<div class="bg-gradient-to-br from-red via-green to-blue from-10% via-10% to-20%"></div>

5. 声明变量

html 复制代码
<div class="[--color:theme(colors.red.500)] [--bg:red] bg-[--bg] color-[--color]"></div>

6. 伪类元素

html 复制代码
<div class="before:content-[''] before:block before:size-3 before:bg-red"></div>

7. 占位符

html 复制代码
<div class="placeholder:color-red"></div>

8. 响应式

html 复制代码
<div class="sm-<md:w-full"></div>

9. 包含属性样式(disabled, read-only, checked ...等等)

html 复制代码
<div class="disabled:opacity-30 read-only:bg-gray-100 checked:ring-1 required:border-1"></div>

10. data属性样式(data-hidden ...类似)

html 复制代码
<div class="data-[hidden]:hidden"></div>

更多样式请参考 unocss

相关推荐
读心悦6 小时前
CSS:盒子阴影与渐变完全解析:从基础语法到创意应用
前端·css
椒盐螺丝钉11 小时前
CSS 基础知识分享:从入门到注意事项
前端·css
冬阳春晖11 小时前
web animation API 锋利的css动画控制器 (更新中)
前端·javascript·css
森哥的歌12 小时前
CSS Layer 详解
css·css3·web开发·前端开发·样式表
哈桑compile16 小时前
用纯HTML和CSS仿写知乎登录页面
前端·css·html
想不明白的过度思考者17 小时前
为了结合后端而学习前端的学习日志(1)——纯CSS静态卡片案例
前端·css·学习
^小桃冰茶1 天前
CSS知识总结
前端·css
chéng ௹1 天前
vue2 上传pdf,拖拽盖章,下载图片
前端·css·pdf
A_aspectJ1 天前
【Bootstrap V4系列】学习入门教程之 组件-输入组(Input group)
前端·css·学习·bootstrap·html
sunbyte1 天前
Tailwind CSS v4 主题化实践入门(自定义 Theme + 主题模式切换)✨
前端·javascript·css·tailwindcss