scss的使用方法
引用scss文件——看上一篇的less使用,里面的Koala,一样的原理!!!

方法一:
scss:
/**
定义变量
*/
$width:404px;
$color:green;
$font-size:20px;
.scss1{
width: $width;
height: $width/2;
background-color: $color;
font-size: $font-size;
}
css:
.scss1{width:404px;height:202px;background-color:green;font-size:20px}
html:
<h1>定义变量</h1>
<div class="scss1">Hello Scss</div>

方法二:
scss:
/**
嵌套(可以多层)
*/
.scss2{
width: 100px;
height: 100px;
background-color: green;
.scss3{
width: 200px;
height: 100px;
background-color: red;
.scss4{
width: 300px;
height: 100px;
background-color: yellow;
}
}
}
css:
.scss2{width:100px;height:100px;background-color:green}.
scss2 .scss3{width:200px;height:100px;background-color:red}
.scss2 .scss3 .scss4{width:300px;height:100px;background-color:yellow}
html:
<h1>嵌套</h1>
<div class="scss2">Hello Scss
<div class="scss3">Hello Scss
<div class="scss4">Hello Scss</div>
</div>
</div>
方法三:
scss:
/**
导入
*/
@import "index2";
.scss5{
font-size: $font-size;
background-color: $bgc;
width: $width;
height: 100px;
}
css:
*{margin:0;padding:0}.scss5{font-size:30px;background-color:brown;width:404px;height:100px}
html:
<h1>导入</h1>
<div class="scss5">Hello Scss</div>

方法四:
scss:
/**
mixin 混入
用@include调用(可带参数)
*/
@mixin scss6($width:100px,$height:100px,$color:lightblue){
width: $width;
height: $height;
background-color: $color;
border: $width/10;
}
.scss6{
//用include调用申明的方法
@include scss6();
}
.scss7{
//带参
@include scss6($color:red);
}
css:
.scss6{width:100px;height:100px;background-color:#add8e6;border:10px}.scss7{width:100px;height:100px;background-color:red;border:10px}
html:
<h1>mixin混入</h1>
<div class="scss6">Hello Scss</div>
<div class="scss7">Hello Scss</div>

方法五:
scss:
/**
扩展/继承
*/
.scss_all{
width: 100px;
height: 100px;
background-color: darkred;
text-align: center;
}
.scss_all_item1{
@extend .scss_all;
background-color: lightgreen;
}
.scss_all_item2{
@extend .scss_all;
background-color: lightblue;
}
css:
.scss_all,.scss_all_item1,.scss_all_item2{width:100px;height:100px;background-color:darkred;text-align:center}
.scss_all_item1{background-color:lightgreen}.scss_all_item2{background-color:lightblue}
html:
<h1>扩展/继承</h1>
<div class="scss_all">darkred</div>
<div class="scss_all_item1">lightgreen</div>
<div class="scss_all_item2">lightblue</div>
方法六:
scss:
/**
运算
*/
.scss8{
width: (300px+20px)/2+50px/2-20px;
height: 100px;
background-color: #00a3af;
}
css:
.scss8{width:165px;height:100px;background-color:#00a3af}
html:
<h1>运算</h1>
<div class="scss8">Hello Scss</div>

方法七:
scss:
/**
函数
*/
$color:#999ccc;
.color_item{
color: $color;
&:hover{
background-color: darken($color,50%);//变暗
}
}
.color_item2:hover{
color: lighten(red,1%);//变亮
}
css:
.color_item{color:#999ccc}.color_item:hover{background-color:#222444}
.color_item2:hover{color:#ff0505}.font-1{font-size:14px;color:#ffacb8}
html:
<h1>颜色函数</h1>
<div class="color_item">123</div>
<div class="color_item2">123</div>
方法八:
scss:
/**
流程控制
*/
$blur:lightpink;
@for $i from 1 through 10{//i=from后面的数字
.font-#{$i} {
font-size: 12px+$i*2px;
color: darken($blur, $i*2);
@if $i%2==0{//判断i除以2余=0
text-decoration: underline;
}
}
}
css:
.font-1{font-size:14px;color:#ffacb8}.font-2{font-size:16px;color:#ffa2b0;text-decoration:underline}
.font-3{font-size:18px;color:#ff97a7}.font-4{font-size:20px;color:#ff8d9e;text-decoration:underline}.font-5{font-size:22px;color:#ff8396}
.font-6{font-size:24px;color:#ff798d;text-decoration:underline}.font-7{font-size:26px;color:#ff6f84}.font-8{font-size:28px;color:#ff647c;text-decoration:underline}
.font-9{font-size:30px;color:#ff5a73}.font-10{font-size:32px;color:#ff506a;text-decoration:underline}
html:
<h1>流程控制</h1>
<div class="font-1">Hello Scss</div>
<div class="font-2">Hello Scss</div>
<div class="font-3">Hello Scss</div>
<div class="font-4">Hello Scss</div>
<div class="font-7">Hello Scss</div>
<div class="font-8">Hello Scss</div>
<div class="font-9">Hello Scss</div>
<div class="font-10">Hello Scss</div>
scss的使用方法的更多相关文章
- SCSS 使用@each 方法循环遍历数组颜色并给li赋值
$list-bg:red,orange,blue,skyblue; ul{ >li{ height: 30px; @each $c in $list-bg{ $i:index($list-bg, ...
- Sass/Scss 基础篇
Sass/Scss 基础篇 总结Sass学习到的内容 应用Sass/Scss前,环境配置 首先下载Ruby (http://rubyinstaller.org/downloads) 通过命令下载sas ...
- sass中级语法
github地址:https://github.com/lily1010/sass/tree/master/course02 用到的sass语法是: sass --watch test.scss:te ...
- vue stylus 格式化问题
IDE是vscode 安装了.vetur插件 由于stylus可以仅用缩进不用写大括号之类的,所以十分方便, 但有个问题,按alt shift F 格式化时,vetur这个插件会默认添加上正常css的 ...
- Sass 增强语法的样式表
功能: 完全兼容CSS3 相对CSS,扩展了变量.嵌套和mixins 对控制颜色和其他值的非常有用的方法 高级功能,如库的直接控制 良好的格式,自定义输出 语法 对于Sass,有两种语法. 一种叫SC ...
- 表析LESS、Sass和Stylus的异同
. 首页 博客园 联系我 前言:CSS预处理语言. 基本差别. 基本语法. 变量与作用域. 混合(Mixins). 嵌套实现后代选择器. 继承. 条件语句. 循环语句. 综合对比. 留言评论 返回顶部 ...
- 在 Vuejs 项目中如何定义全局变量 全局函数
在 Vuejs 项目中如何定义全局变量 全局函数 在项目中,经常有些函数和变量是需要复用,比如说网站服务器地址,从后台拿到的:用户的登录 token, 用户的地址信息等,这时候就需要设置一波全局变量和 ...
- 《移动Web前端高效开发实战》笔记2——使用Gulp构建一个ECMAScript 6和Sass应用
8.3.1 安装和配置 运行Gulp需要Node.js环境,请参看第二章内容搭建Node.js环境.使用NPM全局安装Gulp,命令如下: npm install gulp-cli –g 然后,在项目 ...
- uni-app中使用sass
uni-app在创建时,工程目录下会有个uni.scss文件,我们可以直接在里面定制化scss变量. 全局scss中的坑: 1.如果要引用全局外部scss文件,可以考虑在uni.scss这个系统全局s ...
随机推荐
- 丽泽普及2022交流赛day19 半社论
目录 No Problem Str Not TSP 题面 题解 代码 Game 题面 题解 代码 No Problem 暴力 Str 存在循环节,大力找出来即可,长度显然不超过 \(10^3\) . ...
- 5.1SpringBoot整合Kafka(工具安装Kafka+Tools)
1.工具安装Kafka 上一期我分享了安装zk,下一次我们把Kafka和可视化工具一起搞起来. 注意:这个时候ZK一定要启动成功. zk安装地址:https://www.cnblogs.com/dao ...
- 4.直方图介绍和使用|MySQL索引学习
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 目录 一.导读 二.步骤 2.1 SQL语句 2.2 直方图案例 2.3 查看直方图统计信息 2.3 直方图分类 2.4 ...
- 在docker中出现的僵尸进程怎么处理
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 一.发现问题 小玲是一名数据库测试人员,这一天她尝试在docker环境中部署GreatDB集群,结果在对greatsqld ...
- 浅淡 Apache Kylin 与 ClickHouse 的对比
作者简介 周耀,Kyligence 解决方案架构师,Apache Kylin.Apache Superset Contributor. Apache Kylin 和 ClickHouse 都是目前市场 ...
- java-引用数组、继承、super关键字
1.引用类型数组: 1) Cell[] cells = new Cell[4]; cells[0] = new Cell(2,5); cells[1] = new Cell(2,6); cel ...
- MySQL启动报:[ERROR] The server quit without updating PID file
修改配置后MySQL启动不了,报错: [root@localhost mysql]# service mysql restart Starting MySQL...[ERROR] The server ...
- 简单概述因特网(Internet)
学习目的 了解 Internet 的概念,区别因特网与互联网. 了解 Internet 的基本结构. 了解 Internet 的发展历史. Internet 概念 因特网(Internet)是全球性的 ...
- GoogleTest环境配置以及应用
1 GoogleTest源码编译: GoogleTest代码仓库URL: https://github.com/google/googletest.git 下载源代码: git clone --bra ...
- 【Java】学习路径62-枚举类型
public enum Role { TEACHER,STUDENT,CHEF } 使用: System.out.println(r1);//输出TEACHER System.out.println( ...



