Sass预定义一些常用的样式
一.编写sass文件时, 目录不能有中文, 如: E:\\CPC手机, 会报错
exception while processing events: incompatible character encodings: GBK and UTF-8?
二.检测sass目录
$ sass --watch sass:styles
三.引入外部的scss、使用变量, 如index.scss文件引入base.scss文件, 使用es6 import语法
@import "./base.scss";
四.语法
1.变量: $defalutView: 750px;
2.函数: @function rem($px){
@return ($px / $defalutView) * 10rem;
}
3.混合: @mixin maxWidth($maxWidth:640px){
max-width:$maxWidth;
}
五.Sass预定义一些常用的样式
1.三角形
@mixin arrow($direction, $size, $color){
width:0;
height:0;
line-height:0;
font-size:0;
overflow: hidden;
border-width:$size;
@if $direction == top {
border-style: dashed dashed solid dashed;
border-color: transparent transparent $color transparent;
border-top: none;
}
@else if $direction == bottom {
border-style: solid dashed dashed dashed;
border-color: $color transparent transparent transparent;
border-bottom: none;
}
@else if $direction == right {
border-style: dashed dashed dashed solid;
border-color: transparent transparent transparent $color;
border-right: none;
}
@else if $direction == left {
border-style: dashed solid dashed dashed;
border-color: transparent $color transparent transparent;
border-left: none;
}
}
// 调用 @include arrow(top,10px,#F00);
2. 圆角
@mixin border-radius($px:5px){
-webkit-border-radius:$px;
-moz-border-radius:$px;
-o-border-radius:$px;
border-radius:$px;
}
@mixin border-radius-circle(){
border-radius:50%;border-top-left-radius: 999px;border-top-right-radius: 999px;border-bottom-right-radius: 999px; border-bottom-left-radius: 999px; border-radius: 999px;background-clip: padding-box;
}
3.超出的文本省略
@mixin ell(){
overflow: hidden;
-ms-text-overflow: ellipsis;
text-overflow:ellipsis;
white-space: nowrap;
}
@mixin ellMore($lineNumber:2){
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $lineNumber;
-webkit-box-orient: vertical;
}
4.关于flex布局
@mixin flex-box{
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flex;
display: flex;
}
@mixin flex-1($percent){
width:$percent;
-webkit-box-flex: 1;
-webkit-flex: 1;
-moz-box-flex: 1;
-ms-flex: 1;
flex: 1;
}
@mixin justify-content{
-webkit-justify-content:space-between;
justify-content:space-between;
}
5.盒子标准
@mixin box-sizing {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-o-box-sizing:border-box;
box-sizing:border-box;
}
6.绝对居中
@mixin center($width, $height) {
position: absolute;
left:50%;
top:50%;
width:$width;
height:$height;
margin:(-$height / 2) 0 0 (-$width / 2);
}
7.设置过渡
@mixin transition($transition...) {
-webkit-transition:$transition;
-moz-transition:$transition;
-o-transition:$transition;
transition:$transition;
}
// 调用 @include transition(all 0.3s ease)
8.动画
@mixin animation($name) {
-webkit-animation:$name;
-moz-animation:$name;
-o-animation:$name;
animation:$name;
}
// 调用 @include animation(test 1s infinite alternate both)
9.设置关键帧
@mixin keyframes($name) {
@-webkit-keyframes #{$name} {
$browser: '-webkit-'; @content;
}
@-moz-keyframes #{$name} {
$browser: '-moz-'; @content;
}
@-o-keyframes #{$name} {
$browser: '-o-'; @content;
}
@keyframes #{$name} {
$browser: ''; @content;
}
}
10.设置旋转位置
@mixin transform-origin($origin...) {
-webkit-transform-origin:$origin;
-moz-transform-origin:$origin;
-o-transform-origin:$origin;
transform-origin:$origin;
}
@mixin transform($transform...) {
-webkit-transform:$transform;
-moz-transform:$transform;
-o-transform:$transform;
transform:$transform;
}
11.Sass里for来快速现实对图片的定位
@for $i from 0 to 17{
.d-icon-#{$i}{ background-position: -0 -#{+ $i*30}px; }
}
// css生成
.d-icon-0 { background-position: 0 -0px; }
.d-icon-1 { background-position: 0 -30px; }
.d-icon-2 { background-position: 0 -60px; }
.d-icon-3 { background-position: 0 -90px; }
.d-icon-4 { background-position: 0 -120px; }
.d-icon-5 { background-position: 0 -150px; }
.d-icon-6 { background-position: 0 -180px; }
.d-icon-7 { background-position: 0 -210px; }
.d-icon-8 { background-position: 0 -240px; }
.d-icon-9 { background-position: 0 -270px; }
.d-icon-10 { background-position: 0 -300px; }
.d-icon-11 { background-position: 0 -330px; }
.d-icon-12 { background-position: 0 -360px; }
.d-icon-13 { background-position: 0 -390px; }
.d-icon-14 { background-position: 0 -420px; }
.d-icon-15 { background-position: 0 -450px; }
.d-icon-16 { background-position: 0 -480px; }
Sass预定义一些常用的样式的更多相关文章
- 使用Sass预定义一些常用的样式,非常方便(转)
SS预处理技术现在已经非常成熟,比较流行的有Less,Sass,Stylus,在开发过程中提升我们的工作效率,缩短开发时间,方便管理和维护代码,可以根据自己的喜好选择一款自己喜欢的工具开发,使用很接近 ...
- 使用Sass预定义一些常用的样式,非常方便
CSS预处理技术现在已经非常成熟,比较流行的有Less,Sass,Stylus,在开发过程中提升我们的工作效率,缩短开发时间,方便管理和维护代码,可以根据自己的喜好选择一款自己喜欢的工具开发,使用很接 ...
- boostrap预定义样式风格
预定义样式分为五种:primary(首选项).success(成功).info(一般信息).warning(警告).danger(危险),demo如下,设置不同的class展示不同的样式 <!D ...
- PHP常用的预定义常量
<?php echo 'PHP常用的预定义常量'.'<br><br>'; echo '当前php的版本为(PHP_VERSION):'.PHP_VERSION.'< ...
- bootstrap 预定义样式风格
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 五十九、SAP中常用预定义系统变量
一.SAP中常用预定义系统变量 内容如下: 二.系统变量定义在结构SYST里,我们打开SE38 三.在代码编辑器输入SYST变量 四.双击SYST,来到这个系统结构,里面有很多系统变量 五.我们随便写 ...
- 五十八、SAP中常用预定义数据类型
一.SAP中常用预定义数据类型 注意事项如下: 1.默认的定义数据类型是CHAR. 2.取值的时候C型默认从左取,N型从右取,超过定义长度则截断. 3.C类型,可以赋值数值,也可以赋值字符,还可以混合 ...
- PHP预定义接口之 ArrayAccess
最近这段时间回家过年了,博客也没有更新,感觉少学习了好多东西,也错失了好多的学习机会,就像大家在春节抢红包时常说的一句话:一不留神错过了好几亿.废话少说,这篇博客给大家说说关于PHP预定义接口中常用到 ...
- .NET中那些所谓的新语法之三:系统预定义委托与Lambda表达式
开篇:在上一篇中,我们了解了匿名类.匿名方法与扩展方法等所谓的新语法,这一篇我们继续征程,看看系统预定义委托(Action/Func/Predicate)和超爱的Lambda表达式.为了方便码农们,. ...
随机推荐
- JavaSE(二)之继承、封装、多态
学习完类与对象终于认识到什么是类,什么是对象了.接下来要看的就是java的三大特征:继承.封装.多态. 一.封装(数据的隐藏) 在定义一个对象的特性的时候,有必要决定这些特性的可见性,即哪些特性对外部 ...
- 6 Django系列之关于models的sql语句日常用法总结
preface Django提供了强大的ORM,我们可以通过ORM快速的写出我们想要对数据做什么样操作的代码.下面就说说我在日常工作中的用法: 外键关联精确查询 应用场景:表A host字段关联到了表 ...
- 安装MySQL后经常弹出taskeng.exe~
taskeng.exe,是Microsoft任务计划程序引擎调用的安全进程.文件路径为C:\Windows\system32\taskeng.exe.大小165KB. 解决办法: 这个问题是Wind ...
- mysql中查看视图的元数据?
需求描述: 查看视图的元数据的方法. 操作过程: 1.通过查看information_schema数据库下的views表来查看视图的定义语句 mysql> select definer,view ...
- 常见bootloader介绍
https://blog.csdn.net/weibo1230123/article/details/82716818 http://fasight001.spaces.eepw.com.cn/art ...
- less语法(一)变量与extend
摘要: 作为 CSS 的一种扩展,Less 不仅完全兼容 CSS 语法,而且连新增的特性也是使用 CSS 语法.这样的设计使得学习 Less 很轻松,而且你可以在任何时候回退到 CSS.less文件是 ...
- java okhttp发送post请求
java的httpclient和okhttp请求网络,构造一个基本的post get请求,都比py的requests步骤多很多,也比py的自带包urllib麻烦些. 先封装成get post工具类,工 ...
- [Module] 06 - DataBinding and MVVM
下一步学习列表: Android DataBinding使用总结(一) *** Android DataBinding使用总结(二) Android DataBinding使用总结(三)列表展示 An ...
- Java从控制台接受输入字符
创建一个类,在该类的主方法中创建Scanner扫描起来封装System类的in输入流,然后提示用户输入身份证号码,并输入身份证号码的位数. 代码如下: import java.util.Scanner ...
- uploadify在火狐下上传不了的解决方式,java版(Spring+SpringMVC+MyBatis)具体解决方式
因为技术选型的原因,在一个产品中.我选择了uploadify,选择它的原因是它有完好的技术文档说明(http://www.uploadify.com/documentation/),唯一不足的是 ...