sass与compass实战(读书笔记)
// compass create myproject // compass compile
// compass compile --force 重新编译未改动的 // compass compile --output-style compressed
// compass compile --output-style compressed --force // compass watch // compass模块:reset css3 layout typography utilities // 使用变量
$company-blue: #eee;
$basic-border: 1px solid black; // 使用嵌套
// 属性嵌套
nav{
border:{
width: 1px;
style:solid;
color:red;
}
}
nav{
border:1px solid #ccc{
left: ;
right: ;
}
} // 使用混合器来复用一段样式 (混合器在每一个被包含进来的地方就会就地复制一段样式)
@mixin horizontal-list{
li{
float:left;
margin-right:10px;
}
}
#header ul.nav{
@include horizontal-list;
margin-top:10px;
}
#footer ul.nav{
@include horizontal-list;
margin-top:20px;
} // 混合器和变量的结合使用
@mixin horizontal-list($spacing:10px){
li{
float:left;
margin-right:$spacing;
}
}
#header ul.nav{
@include horizontal-list;
margin-top:10px;
}
#footer ul.nav{
@include horizontal-list(20px);
margin-top:20px;
} // 使用继承来避免混合器的复制
.warning{
background-color: #ccc;
}
.other-warning{
@extend .warning;
} // 使用占位符 (上面warning和other-warning都是需要在HTML中使用到的,但有时父类不需要再HTML中使用)
%button-reset{
margin: ;
padding: 5px 12px;
cursor: pointer;
}
.save{
@extend %button-reset;
color: #fff;
}
.delete{
@extend %button-reset;
color: #;
} // Compass是一个强大的Sass框架,自身包含了很多有Sass混合器和函数构成的模块 @import "compass/reset"; //重置 @import "compass/reset/utilities"; //基础辅助作用,使下面的global-reset可用
@include global-reset;
// @include reset-html5; @import "compass/utilities/tables"; //表格
.table{
$table-color:#;
width: %;
@include table-scaffolding; //base table style
@include inner-table-borders(1px,darken($table-color,%)); //table inner-border
@include outer-table-borders(1px); //table outer-border
@include alternating-rows-and-columns($table-color,adjust-hue($table-color,-120deg),#); //th and td color
} // 混合器源码
@mixin table-scaffolding{
th{
text-align: center;
font-weight: bold;
}
td,th{
padding: 2px;
&.numeric{
text-align: right;
}
}
} @import "compass/css3"; //CSS3
.rounded{
@include border-radius(5px);
@include border-corner-radius(top,left,20px);
} // 如果你并不打算支持所有的浏览器厂商
$experimental-support-for-opera:false;
$experimental-support-for-microsoft:false;
$experimental-support-for-khtml:false; @include box-shadow(#ccc 5px 5px 2px);
@include text-shadow(
rgba(#,.) -200px ,
rgba(#,.) -400px ,
rgba(#,.) -600px ,
rgba(#,.) -800px
);
@include box-shadow(
rgba(#,.) -200px ,
rgba(#,.) -400px ,
rgba(#,.) -600px ,
rgba(#,.) -800px
);
@include background( 渐变
linear-gradient(
360deg,
#bfbfbf %,
#bfbfbf 12.5%,
#bfbf00 12.5%,
#bfbf00 %,
#00bfbf 37.5%,
#00bfbf 37.5%,
#00bf00 %,
#00bf00 %,
#bf00bf 62.5%,
#bf00bf 62.5%,
#bf0000 %,
#bf0000 %,
#0000bf 87.5%,
# %
)
); // https://www.google.com/fonts/ Google字体的使用 // Sass允许 @import 命令写在CSS规则内
.blue-theme{
@import "blue-theme";
} // 可以把原始的CSS文件改名为.SCSS后缀,即可直接导入了 // 这种注释内容不会出现在生成的css文件中
/* 这种注释内容会出现在生成的css文件中 */ // 混合器中不仅可以包含属性,也可以包含CSS规则,包含选择器和选择器中的属性
@mixin no-bullets{
list-style: none;
li{
margin-left: 10px;
}
} // 给混合器传参
@mixin link-colors($normal,$hover){
color: $normal;
&:hover{
color: $hover;
}
}
a{
@include link-colors(blue,red);
}
// ..........................设默认值...................
@mixin link-colors($normal:blue,$hover:red){
color: $normal;
&:hover{
color: $hover;
}
}
a{
@include link-colors(blue,red);
} // 不要用后代选择器去继承!!!
.foo .bar{
@extend .bar;
} // ...................................网络布局..............................
// 所有的CSS网络布局都有列的概念,并且这些列在同一容器内是等宽的 @import "compass/typography"; //更快更直观的排版工具 @include link-colors(#,red); //默认和hover时的颜色
@include hover-link; //添加下划线
@include unstyled-link; //隐形的链接
@include pretty-bullets('a.png'); //装点列表 注意是加在ul上面喔
ul.features{
@include pretty-bullets('a.png');
} // pretty-bullets混合器使用了image-url辅助器,它可以在开发环境和生产环境返回各自不同的完整路径 // 去掉项目符号
li.no-bullet{
@include no-bullet;
}
ul.no-bullet{
@include no-bullets;
} @include horizontal-list; //轻松横向排列 对于支持:first-child和.last-child的浏览器,则省去了两遍元素的padding,对于低版本浏览器,则可以使用.first和.last
ul.nav{
// @include horizontal-list;
@include horizontal-list(10px,right); //改变列表间距并颠倒次序并右浮动
} @include delimited-list; //让列表看起来像文字排列一样哈
ul.words{
@include delimited-list("! ");
} @include ellipsis; //点点点
@include nowrap; //防止折行 @include replace-text("a.png"); //用图片来替换文字 @import "compass/layout"; //布局模块 // 粘滞的页脚
<div id="content">
start<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>end
<div id="blank"></div>
</div>
<div id="footer">停靠在页脚的内容</div> @include sticky-footer(80px,"#content","#blank","#footer"); //利用margin-bottom负值实现:无论content内容多少,footer永在最下面 @include stretch(15px,15px,15px,15px); //流布局 // ................................Compass精灵,重!.....................................
@import "compass/utilities/sprites"; $icon-spacing:30px; //设置间距
$icon-a-spacing:60px; //设置图片a的间距
$icon-repeat: no-repeat; //设置精灵的重复性
$icon-a-repeat:repeat-x;
$icon-position:; //设置精灵的偏移量
$icon-b-position:%;
$icon-layout:vertical/horizontal/diagonal/smart; //对于采用智能布局或对角线布局的精灵地图,位置和重复性的设置是无效的
$icon-clean-up:true/false; //清除过期的精灵地图 @import "icon/*.png"; @include all-icon-sprites; //可写可不写
.icon1{
@include icon-sprite-dimensions(a);
@include icon-sprite(a);
} //设置精灵大小的3种方式
$icon-sprite-dimensions:true; //头部给整体设置 width: icon-sprite-width(a); //样式内部单独设置
height: icon-sprite-height(a); @include icon-sprite-dimensions(a); //样式内部自动设置 //设置精灵的基础类(同样在引入图片之前定义,具体的类不必在引入图片之前定义)
$icon-sprite-base-class:".yangkang";
.yangkang{
border: 2px solid red;
} //魔术精灵选择器 只需要给图片命名 a.png/a_hover.png等等即可
$disable-magic-sprite-selectors:true/false; // ....................驾驭精灵辅助器.....P131待看.................. // 用Sass编写脚本..............略................. Compass函数 (这里无需引入任何模块喔) //返回图片的宽和高
width: image-width("icon/head.png");
height: image-height("icon/head.png");
// 将图片转换为data协议的数据
background-image: inline-image("icon/head.png"); //the path specified should be relative to your project's images directory 我的Compass常用模块总结 @import "compass/reset";
@import "compass/css3/background-size"; //@include background-size;默认background-size:100% auto;
@import "compass/css3/border-radius"; //@include border-radius;默认border-radius:5px;
@import "compass/css3/box-shadow"; //@include box-shadow;默认box-shadow:0px 0px 5px #333333;
@import "compass/css3/box-sizing"; //@include box-sizing(border-box);
@import "compass/css3/inline-block"; //@include inline-block;
@import "compass/css3/opacity"; //@include opacity(.4);
sass与compass实战(读书笔记)的更多相关文章
- sass和compass实战 读书笔记(一)
sass优势: 不做重复的工作 一 消除样式表冗余(通过变量赋值的方式) 1. 通过变量来复用属性值 2. 使用嵌套来快速写出多层级的选择器 3. 通过混合器来复用一段样式 4. 使用选择器继承来避 ...
- 机器学习实战 - 读书笔记(13) - 利用PCA来简化数据
前言 最近在看Peter Harrington写的"机器学习实战",这是我的学习心得,这次是第13章 - 利用PCA来简化数据. 这里介绍,机器学习中的降维技术,可简化样品数据. ...
- 机器学习实战 - 读书笔记(12) - 使用FP-growth算法来高效发现频繁项集
前言 最近在看Peter Harrington写的"机器学习实战",这是我的学习心得,这次是第12章 - 使用FP-growth算法来高效发现频繁项集. 基本概念 FP-growt ...
- 机器学习实战 - 读书笔记(11) - 使用Apriori算法进行关联分析
前言 最近在看Peter Harrington写的"机器学习实战",这是我的学习心得,这次是第11章 - 使用Apriori算法进行关联分析. 基本概念 关联分析(associat ...
- 机器学习实战 - 读书笔记(07) - 利用AdaBoost元算法提高分类性能
前言 最近在看Peter Harrington写的"机器学习实战",这是我的学习笔记,这次是第7章 - 利用AdaBoost元算法提高分类性能. 核心思想 在使用某个特定的算法是, ...
- iPhone与iPad开发实战读书笔记
iPhone开发一些读书笔记 手机应用分类1.教育工具2.生活工具3.社交应用4.定位工具5.游戏6.报纸和杂志的阅读器7.移动办公应用8.财经工具9.手机购物应用10.风景区相关应用11.旅游相关的 ...
- Spring实战读书笔记
Spring实战读书笔记 Spring-core Spring之旅 - DI 和 AOP 概念 spring 的Bean容器 spring 的 核心模块 Spring的核心策略 POJO 最小侵入式编 ...
- <<Java RESTful Web Service实战>> 读书笔记
<<Java RESTful Web Service实战>> 读书笔记 第一章 JAX-RS2.0入门 REST (Representational State ransf ...
- [已读]Sass与Compass实战
介绍了Sass基础语法与Compass框架,这个网上参考文档就OK了,另外介绍了compass生成图片精灵和相应的css,貌似现在单纯用sass和compass的挺少,要不grunt,要不FIS,而g ...
随机推荐
- 深入了解Struts1的执行机理
要说Struts1的工作流程.就必需要说一下Model1和Model2了.由于这个框架是踏着他们的尸骨一步一步的发展起来的. Model1开发模式,想想我们刚刚開始接触Java的时候,我们用的就是这样 ...
- 并发insert情况下数据重复插入问题的解决方案
背景介绍 通常我们在接口里要保存一条数据时,会先判断该条记录在数据库里是否存在,如果不存在就插入,如果存在就返回已经存在. 就拿常见的工单来举例 Order order = orderService. ...
- HDU 2242 考研路茫茫——空调教室(边双连通)
HDU 2242 考研路茫茫--空调教室 题目链接 思路:求边双连通分量.然后进行缩点,点权为双连通分支的点权之和,缩点完变成一棵树,然后在树上dfs一遍就能得出答案 代码: #include < ...
- Tinker 热修复框架 简单上手教程
当你们看到Tinker的时候是不是有点愣逼这个是什么东西? 简单来说就是不需要重新下载app和重新安装app 来进行更新app的技术框架. 看看这个吧,我也是才学习 ,先做个学习记录 参考:Tinke ...
- RPMBUILD源码打包资源汇总(转)
http://mattshma.github.io/2015/11/04/rpm%E6%89%93%E5%8C%85/ http://400053.blog.51cto.com/390053/7210 ...
- Struts2 ModelDriven接口使用
用户在做http请求时一般都有两种方式:get和post方式.get方式用来获取查询相关信息,既向服务器获得信息,而post方式用来更新信息既向服务器提交数据.通常情况下,用get方式向服务器获取信息 ...
- 高性能流媒体服务器EasyDSS前端重构(二) webpack + vue + AdminLTE 多页面提取共用文件, 优化编译时间
本文围绕着实现EasyDSS高性能流媒体服务器的前端框架来展开的,具体EasyDSS的相关信息可在:www.easydss.com 找到! 接上回 <高性能流媒体服务器EasyDSS前端重构(一 ...
- 九度OJ 1046:求最大值 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9861 解决:4013 题目描述: 输入10个数,要求输出其中的最大值. 输入: 测试数据有多组,每组10个数. 输出: 对于每组输入,请输 ...
- 性能测试--Jmeter随机生成/随机选取/csv读取关键字
Jmeter随机生成/随机选取/csv读取关键字 一.随机生成关键字 随机生成关键字,需要组件:随机变量配置元件(Random Variable) 该组件的作用是生成字符+随机数字格式的字符串,并保 ...
- 性能测试--siege
siege 这是Linux系统下的一个测试工具,完全使用C语言实现,可以对HTTP和FTP服务器进行负载和性能测试.通过使用Siege 提供的功能,可以很容易的制定测试计划:包括规定使用并发用户数.重 ...