飞翔的鱼 飞翔的鱼
首页
  • Http
  • Ajax
  • Node
  • MongoDB
  • Axios
  • Git
  • Webpack
  • React
  • Vue
  • Uni-app
  • 性能优化
  • 移动端
  • HTML
  • CSS
  • stylus
  • 常用
  • 实战
  • 实用网站
  • 资源库
  • Vue专区
关于
  • css效果
  • js效果
  • 拥抱生活
  • 生活知道
GitHub (opens new window)

Wang

飞翔的鱼
首页
  • Http
  • Ajax
  • Node
  • MongoDB
  • Axios
  • Git
  • Webpack
  • React
  • Vue
  • Uni-app
  • 性能优化
  • 移动端
  • HTML
  • CSS
  • stylus
  • 常用
  • 实战
  • 实用网站
  • 资源库
  • Vue专区
关于
  • css效果
  • js效果
  • 拥抱生活
  • 生活知道
GitHub (opens new window)
  • HTML

  • CSS

  • stylus

    • stylus
      • 4. stylus使用
  • 页面
  • stylus
wang jiaqi
2020-02-23

stylus

# 4. stylus使用

  1. stylus安装使用

    1. 脚手架中使用 1. npm install stylus stylus-loader
    2. style标签设置: lang="stylus" rel="stylesheet/stylus"
  2. stylus语法介绍

    1. 特点

      1. 简写大括号

      2. 简写封号

      3. 样式嵌套,层级明显

        #app
            h1
              color $color
            .btn1
              btnStyle(100px, 100px, red)
            .btn2
              btnStyle(200px, 200px, blue)
            .content
              font-size 24px
              &.content1
                color $color·
        
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
    2. 定义变量:复用

      $color = red
      
      1
    3. 定义混合(mixins):代码复用,提高效率,灵活度高,等同于js的函数

       btnStyle(w, h, bg)
          width w
          height h
          background bg
          border none
      
      1
      2
      3
      4
      5
    4. 定义函数: 可进行计算,灵活度更高

      // 定义函数
      add(a, b)
          a + b
      // 使用函数
      padding add(10px, 20)
      
      1
      2
      3
      4
      5
    5. 父级引用

      1. 语法:&

      2. 作用:在子元素中能够找到父级元素

         #app
            h1
              color $color
            .btn1
              btnStyle(100px, 100px, red)
            .btn2
              btnStyle(200px, 200px, blue)
            .content
              font-size 24px
              &.content1
                color $color
        
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
    6. 导入文件

        1. 语法: @import ''xx'
      
    7. 其他: [ https://stylus.bootcss.com/ ](

编辑 (opens new window)
上次更新: 2021/07/01, 20:33:02
「css技巧」使用hover和attr()定制悬浮提示

← 「css技巧」使用hover和attr()定制悬浮提示

最近更新
01
数组常用方法
05-21
02
边框
04-30
03
js1
04-29
更多文章>
Theme by Vdoing | Copyright © 2021-2021 本博客仅仅作为自己日常学习记录笔记使用
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×