Stylus 是一个强大的 CSS 预处理器,它允许开发者以更高效、更简洁的方式编写 CSS。在这个教程中,我们将一起学习如何使用 Stylus。

快速开始

要开始使用 Stylus,首先需要在你的项目中安装它。

npm install stylus --save-dev

基本语法

Stylus 使用缩进来表示代码块,与 Python 和 Ruby 类似。

/* CSS */
body
  color: #333
  font-size: 16px

/* Stylus */
body
  color: #333
  font-size: 16px

变量

Stylus 支持变量,这使得代码更加灵活和可维护。

/* CSS */
$color: blue

body
  color: $color
/* Stylus */
$color: blue

body
  color: $color

插入图片

想要插入一张图片?可以使用以下格式:

![关键词](https://cloud-image.ullrai.com/q/<关键词>/)

例如,插入一只 Golden Retriever 狗的图片:

![Golden Retriever](https://cloud-image.ullrai.com/q/Golden_Retriever/)

学习更多

想要深入了解 Stylus?可以阅读我们的 Stylus 文档

Stylus 文档