Sass从0-起飞

作者: GA_ | 来源:发表于2019-03-18 16:16 被阅读1次

前言:sass就是很厉害。

具体看官网即可

  1. 完全兼容 CSS3
  2. 在 CSS 基础上增加变量、嵌套 (nesting)、混合 (mixins) 等功能
  3. 通过函数进行颜色值与属性值的运算
  4. 提供控制指令 (control directives)等高级功能
  5. 自定义输出格式

话归正文

  • 安装

001、安装sass
002、运行sass
003、监视单个sass文件
004、监视整个文件夹

houjianan:~> `sudo gem install sass`

Password:

Fetching: rb-fsevent-0.10.3.gem (100%)

Successfully installed rb-fsevent-0.10.3

Fetching: ffi-1.10.0.gem (100%)

Building native extensions. This could take a while...

Successfully installed ffi-1.10.0

Fetching: rb-inotify-0.10.0.gem (100%)

Successfully installed rb-inotify-0.10.0

Fetching: sass-listen-4.0.0.gem (100%)

Successfully installed sass-listen-4.0.0

Fetching: sass-3.7.3.gem (100%)

Ruby Sass is deprecated and will be unmaintained as of 26 March 2019.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new

  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the

  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:

  http://sass.logdown.com/posts/7081811

Successfully installed sass-3.7.3

Parsing documentation for rb-fsevent-0.10.3

Installing ri documentation for rb-fsevent-0.10.3

Parsing documentation for ffi-1.10.0

Installing ri documentation for ffi-1.10.0

Parsing documentation for rb-inotify-0.10.0

Installing ri documentation for rb-inotify-0.10.0

Parsing documentation for sass-listen-4.0.0

Installing ri documentation for sass-listen-4.0.0

Parsing documentation for sass-3.7.3

Installing ri documentation for sass-3.7.3

Done installing documentation for rb-fsevent, ffi, rb-inotify, sass-listen, sass after 27 seconds

WARNING:  Unable to pull data from 'https://gems.ruby-china.org/': bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

5 gems installed
houjianan:~> `sass test.scss test.css`
houjianan:~> `sass --watch test.scss:test.css`
houjianan:~> `sass --watch app/sass/… `
  • 变量
    $mColor: #123123;
    $mFontSize: 24px;
    #test {
        font-size: $mFontSize;
        color: $mColor;
    }
  • 嵌套
  #mDiv {
        width: 100%;
        height: 100%;
        background-color: red;
        p {
            color: lightcoral;
            text-align: center;
            font-size: 12px;
        }
        span {
        }
        #test {
        }
    }
  • 引用
#_test.css

div {
  background-color: ;
}

p {
    font-size: 12px;
}
  • 引用
@import '../css/resetA';
  • 混合
@mixin border-radius($radius) {
          border-radius: $radius;
      -ms-border-radius: $radius;
     -moz-border-radius: $radius;
  -webkit-border-radius: $radius;
}

.box {
  @include border-radius(8px);
}
  • 继承
    %testDiv {
        background-color: red;
    }
    #content {
        @extend %testDiv;
    }
  • 运算符
    #test {
        width: 100px * 2;
        height: 500px / 3;
    }
  • 嵌套属性
    #testFont {
        font {
            size: 12px;
            color: #00008B;
            weight: bold;
        }
    }
  • &—super
    #testSuper {
        &: hover {

        }
    }

相关文章

  • Sass从0-起飞

    前言:sass就是很厉害。 具体看官网即可 完全兼容 CSS3 在 CSS 基础上增加变量、嵌套 (nesting...

  • H

    从0->1的过程 是幸福的。

  • Sass学习

    Sass学习 介绍 Sass 有两种语法规则(syntaxes),目前新的语法规则(从 Sass 3开始)被称为 ...

  • Vue从0-死亡

    字符串反转 按钮事件 强转字符串 过滤器串联样式 if-else 、if-else if使用 v-show v-f...

  • Flex从0-春风

    Flex例子阮一峰Flex布局教程 语法篇

  • sass笔记-1|Sass是如何帮你又快又好地搞定CSS的

    Sass学习笔记持续整理中,开篇不讲怎么安装,sass是什么,这些搜索引擎会告诉你,我们从sass的作用开始讲起,...

  • SASS - 简介

    SASS – 简介 SASS – 环境搭建 SASS – 使用Sass程序 SASS – SASS – 语法 SA...

  • SASS - 使用Sass程序

    SASS – 简介 SASS – 环境搭建 SASS – 使用Sass程序 SASS – SASS – 语法 SA...

  • SASS - 环境搭建

    SASS – 简介 SASS – 环境搭建 SASS – 使用Sass程序 SASS – SASS – 语法 SA...

  • SASS - 操作符

    SASS – 简介 SASS – 环境搭建 SASS – 使用Sass程序 SASS – SASS – 语法 SA...

网友评论

    本文标题:Sass从0-起飞

    本文链接:https://www.haomeiwen.com/subject/ychbmqtx.html