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 ...
随机推荐
- efcore在Saas系统下多租户零脚本分表分库读写分离解决方案
efcore在Saas系统下多租户零脚本分表分库读写分离解决方案 ## 介绍 本文ShardinfCore版本x.6.0.20+ 本期主角: - [`ShardingCore`](https://gi ...
- C#异步延迟Task.Delay
一. 1.Task.Delay实质是创建一个任务,再任务中开启一个定时间,然后延时指定的时间2.Task.Delay不和await一起使用情况,当代码遇到Task.Delay一句时,创建了了一个新的任 ...
- 使用flex防止fit-content子元素冲出父元素宽度的方法
父元素设置了min-width:fit-content后,其宽度由子元素的宽度来决定 <!DOCTYPE html> <html lang="en"> &l ...
- 1269: 求最长上升子序列(LIS)
题目描述: LIS问题(longest increasing subsequence),即:最长上升子序列问题,是动态规划中一个比较经典的问题.具体描述为:一个有n个整数的序列:A[1],A[2], ...
- 一些JS库汇总
作者:wlove 链接:https://www.zhihu.com/question/429436558/answer/2348777302 来源:知乎 著作权归作者所有.商业转载请联系作者获得授权, ...
- 如果Controller里有私有的方法,能成功访问吗?
目录 背景 原因 cglib代理的锅 换成JDK动态代理呢 参考 背景 写代码的时候,复制粘贴的时候,没注意到方法的属性,就导致了Controller里有了一个私有的方法,然后访问这个接口的时候就报了 ...
- 解决beego运行程序报错问题:stderr: go: github.com/astaxie/beego@v1.12.1: missing go.sum entry
使用命令bee new beegodemo02创建beego程序后,使用VScode打开后,便会报错无法运行,报错信息如下: Error loading workspace: err: exit st ...
- jQuery基础入门(一)
jQuery是什么? jQuery是一个JavaScript常用的工具函数库.jQuery是一个轻量级的"写的少,做的多"的JavaScript库. jQuery当中包含有以下一些 ...
- 大数据Hadoop入门教程 | (二)Linux
使用finalShell可以提供文件目录图形化 完整Linux命令整理参考大佬博客:Linux常见文件管理命令 - Mr_Walker - 博客园 Linux文件系统基础知识 Linux文件系统概念 ...
- Navicat的使用与python中使用MySQL的基本方法
Navicat的使用与python中使用MySQL的基本方法 Navicat的下载及安装 下载地址 http://www.navicat.com.cn/download/navicat-premium ...



