• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

tailwindcss的安装和使用

武飞扬头像
中亿丰数字科技集团有限公司
帮助1

tailwindcss的安装及使用

  1. 安装依赖包,
npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
  1. 初始化,生成 tailwind.config.js 文件,
npx tailwindcss init
  1. 生成 tailwind.css 文件,
npx tailwindcss-cli@latest build -o tailwind.css
  1. 新建 index.html 文件,将tailwind.css文件引入,然后可以使用Live Server启动index.html即可,
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="tailwind.css">
    <title>tailwindcss Demo</title>
</head>
<body>
    <div class="text-sm text-green-400">测试</div>
</body>
</html>
  1. 使用方法如下,
    可以先在vs code中安装Tailwind CSS IntelliSense插件,这样在写代码时就会有代码提示,
    学新通

举例来说,flex 表示为CSS display:flexjustify-center表示为CSS justify-content:centerobject-fill 表示为CSS object-fit: fill;z-10 表示为CSS z-index: 10;

<div class="text-sm text-green-400">测试</div>
	<div class="container flex justify-center" style="width:100%;">
    <img class="object-fill z-10" src="./img/avatar.png" />
</div>

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhiceefg
系列文章
更多 icon
同类精品
更多 icon
继续加载