stylus快速上手

  • 定義變量,好比一鍵切換主題色

    1.建立xxx.styl文件,定義變量css

$bgColor = #00bcg4

    2.在其餘頁面的style區域裏,先引入這個xxx.styl文件spa

<style>
    @import '../../xxx.styl'  //樣式中引入樣式,要在import前加@
    .header
        height:3rem
        width:.87rem
     color:$bgColor </style>
  • 層級嵌套形式的書寫樣式,而沒必要像css同樣加一堆的父級限制,直接嵌進父級
    .header
      display:felx
      height:80px
      width:100px
      .header-left
        line-height:60px
               height:60px
        float:left
      .header-right
        wigth:30px
  • scoped關鍵字限制了這裏的樣式只對當前頁面有效
    <style lang="stylus" scoped>
相關文章
相關標籤/搜索