2015-1-10 于北京
{
"folders": [{
"path": ".",
"folder_exclude_patterns": ["node_modules", "_site"]//排除目录
}],
"settings": {
"tab_size": 4,
"translate_tabs_to_spaces": true,//tab 转换为空格
"ensure_newline_at_eof_on_save": true,//保存时末尾自动增加一个空行
"trim_trailing_white_space_on_save": true//删除行尾多余的空格
}
}
# css-creating coding style
root = true
# 为所有文件设置风格
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
# 为 Markdown 文件保留行尾空格
[*.md]
trim_trailing_whitespace = false
统一浏览器默认样式
* {
margin: 0;
padding: 0;
}
html, body, dl, dd, dt,
ul, ol, li,
h1, h2, h3, h4, h5, h6, pre, code,
form, fieldset, legend, input, textarea, optgroup,
p, blockquote, figure, hr, menu, dir,
thead, tbody, tfoot, th, td {
margin: 0;
padding: 0;
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
textarea {
resize: vertical;
}
small {
font-size: 85.7%; /* 12/14=0.8571428571 */
}
label {
cursor: pointer;
}
iPhone 横屏时默认会放大文字
html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
更好的:
html {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*, *:before, *:after {
-webkit-box-sizing: inherit;
-moz-box-sizing: inherit;
box-sizing: inherit;
}
body {
font-family: sans-serif;
}
body { font-family:'helvetica neue', arial,
'hiragino sans gb', stheiti,
'microsoft yahei',
'wenquanyi micro hei',
sans-serif;
}
.foo {
transition: width .3s;
-webkit-transition: width .3s;
-moz-transition: width .3s;
-ms-transition: width .3s;
-o-transition: width .3s;
}
.foo {
transition: width .3s; /*标准属性应该放到最后*/
-webkit-transition: width .3s;
-moz-transition: width .3s;
-ms-transition: width .3s; /*IE 不用前缀*/
-o-transition: width .3s;
}
//Scss
@mixin transition($value) {
-webkit-transition: $value;
-moz-transition: $value;
-o-transition: $value;
transition: $value;
}
.foo {
@include transition(width .3s);
}
//Stylus
transition(value) {
-webkit-transition: value;
-moz-transition: value;
-o-transition: value;
transition: value;
}
.foo {
transition(width .3s);
//或者
transition: width .3s;
}
.foo {
-webkit-transition: width .3s;
-moz-transition: width .3s;
-o-transition: width .3s;
transition: width .3s;
}
.bra {
-webkit-transition: margin .6s;
-moz-transition: margin .6s;
-o-transition: margin .6s;
transition: margin .6s;
}
.foo .bar {
-webkit-transition: width .3s;
-moz-transition: width .3s;
-o-transition: width .3s;
transition: width .3s;
}
.clearfix {
*zoom: 1;
}
.clearfix:after {
clear: both;
}
.clearfix:before,
.clearfix:after {
content: ' ';
display: table;
}
...
...
...
...
...
.foo{
clear: fix;
/* or */
+clear: fix;
}
.foo {
clear: fix;
overflow: hidden; /* 已经可以闭合浮动了 */
}
.foo {
overflow: hidden; /* 已经可以闭合浮动了 */
}
.foo {
position: center;
width: 400px;
height: 310px;
}
CSS Grace 展望
//多行溢出显示省略号
.foo {
text-overflow: ellipsis;
max-lines: 4;
}
//自定义三角属性
.bar {
triangle: top 10px red;
triangle: top-right 20px #ccc;
}
var gulp = require('gulp');
var rename = require('gulp-rename');
var postcss = require('gulp-postcss');
var cssgrace = require('cssgrace');
gulp.task('default', function () {
var processors = [
cssgrace
];
return gulp.src('src/*.css')
.pipe(postcss(processors))
.pipe(rename('gulp.css'))
.pipe(gulp.dest('build'))
});
gulp.watch('src/*.css', ['default']);
《CSS 工作流》