隨筆記錄36 sass安裝及使用

一、安裝、配置

  1. 安裝Ruby
    window下安裝SASS首先需要安裝Ruby(https://rubyinstaller.org/downloads/
    注意:安裝過(guò)程中請(qǐng)注意勾選Add Ruby executables to your PATH添加到系統(tǒng)環(huán)境變量
  2. 刪除替換原gem源(sass中文網(wǎng))
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
//打印是否替換成功
gem sources -l
https://gems.ruby-china.com
  1. sass安裝
gem install sass
gem install compass
  1. 編譯器配置(idea)
    File->Settings->Tools->File Watchers
    點(diǎn)擊右上角的+號(hào),選擇compass scss
    program:選擇 Ruby27-x64\bin\scss.bat
    Arguments里面填
--no-cache --update $FileName$:$FileNameWithoutExtension$.css

二、使用(只記錄部分)

  1. 使用變量
$nav-color: #F90;
nav {
  width: 100px;
  color: $nav-color;
}
  1. 嵌套
#content {
  article {
    h1 { color: #333 }
    p { margin-bottom: 1.4em }
  }
}
//編譯后
#content article h1 { color: #333 }
#content article p { margin-bottom: 1.4em }

3.父選擇器的標(biāo)識(shí)符&(常用語(yǔ)偽類)

article a {
  color: blue;
  :hover { color: red }
}
//編譯后
article a { color: blue }
article a:hover { color: red }

4.混合器

@mixin rounded-corners {
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
}
notice {
  background-color: green;
  border: 2px solid #00aa00;
  @include rounded-corners;
}

//編譯后
.notice {
  background-color: green;
  border: 2px solid #00aa00;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容