速记法字体(Shorthand Font)
font: style variant weight size/line-height family
最后两个必须是font-size[/line-height] 和font-family, 其他属性可以任意顺序.
|
|
使用常用字体
Serif Fonts | Sans-Serif Fonts | Monospace and Fun Fonts |
---|---|---|
“Times New Roman”, Times, serif | Arial, Helvetica, sans-serif | “Courier New”, Courier, monospace |
Georgia, “Times New Roman”, Times, serif | Verdana, Arial, Helvetica, sans-serif | “Lucida Console”, Monaco, monospace |
Baskerville, “Palatino Linotype”, Times, serif | Geneva, Arial, Helvetica, sans-serif | “Copperplate Light”, “Copperplate Gothic Light”, serif |
“Hoefler Text”, Garamond, Times, serif | Tahoma, “Lucida Grande”, Arial, sans-serif | “Marker Felt”, “Comic Sans MS”, fantasy |
“Century Gothic”, “Gill Sans”, Arial, sans-serif |
使用Web字体
字体文件格式(Types):
- EOT Embedded OpenType .eot
- TrueType, OpenType .ttf .otf
- WOFF Web Open Font Format .woff
- SVG Scalable Vector Graphic .svg
寻找Web字体
- The League of Moveable Type theleagueofmoveabletype
- Exljbris font foundry http://www.exljbris.com/
- The Open font Library http://openfontlibrary.org
- Font Squirrel https://www.fontsquirrel.com
- Google Fonts https://www.google.com/fonts
生成多种字体格式
using https://www.fontsquirrel.com/tools/webfont-generator
Web字体使用示例
|
|
处理Bold和Italic字体变体(Variants)
|
|
发现Google Web字体
给文点颜色看看
色彩的表示方法(Representation):
- Hexadecimal Color Nation
#0066FF
- RGB / RGBA
rgb(100%, 100%, 100%); rgb(255,255,255); rgba(255, 100, 50, .5)
- HSL / HSLA
hsl(0-360, 100%, 50%), hsla(0-360, 50%, 70%, .5)
H: Hue色相
S: Saturation 饱合度, 纯度
L: Lightness 高度
色相: 红, 橙, 黄, 绿, 青, 蓝, 紫: 0-51-102-153-204-255-306-357; 相差约51.
改变字体大小
|
|
% 和 em 本质上是一样的, 是相对浏览器默认的字体大小(16px)来计算的, 它们在嵌套的中会通过继承积累效果.
rem (Root em) 与em 相似, 它总是相对根元素(html)来设定字体大小.
格式化单词和字母
- 斜体Italiczing
- 粗体Bolding
- Capitalizing - SMALL CAPS
- 装饰Decorating
- 单词、字母间距Letter/word Spacing
|
|
文本阴影
|
|
格式化段落
行间距
12345{line-height: 150%;line-height: 1.5em;line-height: 1.5;}1.5em
和1.5
区别: 1.5总是通过(font-size of current tag) * 1.5
来计算的.对齐
123{text-align: left | right | center | justify ;}首行缩进
123{text-indent: 25px | 5em | 50%;}text-indent: 50%
表示indent为containing元素宽度的50%.- 段落首字、首行1234{p::first-letter {}.intro::first-line {}}
格式化列表
项目符号种类
123li {list-style-type: squire | disc | circle | decimal | decimal-leading-zero | upper-alpha | lower-alpha | upper-roman | lower-roman | lower-greek | upper-greek .... | none;}项目符号(Bullets and Numbers)的位置
1234567li {list-style-position: inside | outside;}ul, ol {padding-left: 0;margin-left: 0;}图形化项目符号(Graphic Bullets)
123li {list-style-image: url(images/bullet.gif);}url 不需要(quotation marks: ‘ “)包裹