CSS
来自康健生活
引言
CSS 特性,层叠性、继承性和特殊性。
实现
布局
| BFC | Flex | 浮动 |
| stacking context | IFC | 等高布局 |
| 示例 | 示例 | 示例 |
属性
| position | visibility | vertical-align | box-shadow |
| box-sizing | font | 伪类 | pointer-events |
| transform | translate | transition |
word
| word-break | word-wrap | table-layout |
函数
| calc | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
变形
| 拉伸 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
布局
| 浮动布局 | 位置布局 | 表格布局 |
画图
| 画圆 | 三角形 | path |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
关键字
| 蒙层 | 文档流 | 字体 |
| 解析方向 | 层叠上下文 | 隐藏文本 |
| css联动 | 文本 | 阴影 |
问题
| margin合并 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
命名方案
| BEM | scoped css | css modules |
| css-in-js | OOCSS | SMACSS |
| ACSS | 示例 | 示例 |
项目方案
| askgo | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
CSS
CSS Level 1
| REC-CSS1-19961217 | REC-CSS1-19990111 | REC-CSS1-20080411 |
CSS Level 2
| REC-CSS2-20110607 | WD-CSS22-20160412 |
CSS Level 3
| CSS3 |
CSS Level 4 and beyond
CSS Now
| CSS Snapshot 2017 |
备注
语法糖
| cssnext | CSS in JS | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
方案
栅格
栅格布局
| 1010 | 示例 |
标签
| span | div | img |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
动效
| 进度条 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
默认
| user agent stylesheet | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
加载方式
| js异步加载CSS | 分步渲染 | Firefixing |
| hack flexbox | 示例 | 示例 |
| 示例 | 示例 | 示例 |
预处理器
| sass | 示例 | 示例 |
| less | 示例 | 示例 |
| stylus | 示例 | 示例 |
事件
hack
| 雪碧图(css sprite) | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
error
- 相邻元素margin的自动合并与float
- margin塌陷
- h3 标签的 margin-top 自动与父亲节点合并
- 父亲节点设置
overflow: hidden
- display: table-row; border 无效
- 父元素添加 display: table; border-collapse: collapse;
测量工具
编辑器
在线编辑
清楚默认样式
Normalize.css
Normalize.css 尽量保留浏览器的默认样式,不进行过多的重置。
normalize.css
html {
line-height: 1.15;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
main {
display: block;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
pre {
font-family: monospace, monospace;
font-size: 1em;
}
a {
background-color: transparent;
}
abbr[title] {
border-bottom: none;
text-decoration: underline;
text-decoration: underline dotted;
}
b,
strong {
font-weight: bolder;
}
code,
kbd,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
small {
font-size: 80%;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
img {
border-style: none;
}
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
font-size: 100%;
line-height: 1.15;
margin: 0;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
fieldset {
padding: 0.35em 0.75em 0.625em;
}
legend {
box-sizing: border-box;
color: inherit;
display: table;
max-width: 100%;
padding: 0;
white-space: normal;
}
progress {
vertical-align: baseline;
}
textarea {
overflow: auto;
}
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
padding: 0;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
-webkit-appearance: textfield;
outline-offset: -2px;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
-webkit-appearance: button;
font: inherit;
}
details {
display: block;
}
summary {
display: list-item;
}
template {
display: none;
}
[hidden] {
display: none;
}
Reset.css
Reset.css 会尽可能的清除浏览器的默认样式,以此保持各浏览器标签元素的渲染一致性。
reset.css
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
No categories