一套代码搞定移动端pc端-tailwind 学习(二)

原文个人博客:一套代码搞定移动端pc端-tailwind 学习(二) 支持原文吧!😋css

上一篇博客记录如何安装tailwind,还没看的先去看看吧一套代码搞定移动端pc端-tailwind 学习(一),这篇博客咱们开始学习怎么使用。markdown

前期准备: tailwind有大量的类名,确定是记不住的,此时,咱们确定就要借助插件来提示咱们了,tailwind有 vscode的官方插件: Tailwind CSS IntelliSenseapp

image.png

安装这个插件后,就会有提示了 image.png tailwind 支持使用 @apply 来像普通css的风格那样写。咱们写一段文字,使用mx-auto 来居中显示。oop

<template>
  <div class="main-content">一套代码搞定移动端pc端-tailwind 学习(二)</div>
</template>

<script>
export default {}
</script>

<style >
.main-content {
  @apply container mx-auto 
}
</style>
复制代码

运行结果 image.png 能够看到,主题内容是居中的,但文字不居中 咱们在文档中找到文字居中的属性 text-center,加上属性再运行学习

.main-content {
  @apply container mx-auto text-center
}
复制代码

结果以下: image.png字体

还有一个响应式使用: .main-content { @apply container mx-auto text-center md:text-2xl sm:text-sm } image.pngspa

这个在md 下 字体会大些,在sm下字体会小些 mg下: image.png sm下: image.png插件

使用就是如此简单,下面就是结合文档开始撸页面了~code

相关文章
相关标签/搜索