CSS字体
Font
语法:
font : font-style || font-variant || font-weight || font-size || line-height || font-family
font : caption | icon | menu | message-box | small-caption | status-bar
说明:
设置或检索对象中的文本特性。该属性是复合属性。
默认值为: normal normal normal medium normal "Times New Roman" 。
第一种声明方式参数必须按照如上的排列顺序。每个参数仅允许有一个值。忽略的将使用其参数对应的独立属性的默认值。
示例:
p { font: italic small-caps 600 12pts/18pts 宋体; }
p { font: oblique 100 24pts; }
H1 { font: 15pt/17pt bold "Arial" normal }
color
语法:color : color
取值:color : 指定颜色。
说明:
检索或设置对象的文本颜色。无默认值。注意,用颜色名称指定 color 不被一些浏览器接受。但使用 RGB 值指定颜色能被所有里浏览器识别并正确显示。此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。
示例:
div {color: #345456; }
div { color: rgb(100,14,200); }
font-family
语法:
font-family : name
font-family :ncursive | fantasy | monospace | serif | sans-serif
取值:
name : 字体名称。按优先顺序排列。以逗号隔开。如果字体名称包含空格,则应使用引号括起
第二种声明方式使用所列出的字体序列名称。如果使用fantasy序列,将提供默认字体序列
说明:
设置或检索用于对象中文本的字体名称序列。默认值为 "Times New Roman" 。序列可包含嵌入字体字体。此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。
示例:
div.fixedwidth { font-family: Courier, "Courier New", monospace }
font-size
语法:font-size : xx-small | x-small | small | medium | large | x-large | xx-large | larger | smaller | length
取值:
xx-small : 绝对字体尺寸。根据对象字体进行调整。最小
x-small : 绝对字体尺寸。根据对象字体进行调整。较小
small : 绝对字体尺寸。根据对象字体进行调整。小
x-small : 绝对字体尺寸。根据对象字体进行调整。较小
medium : 默认值。绝对字体尺寸。根据对象字体进行调整。正常
x-small : 绝对字体尺寸。根据对象字体进行调整。较小
large : 绝对字体尺寸。根据对象字体进行调整。大
x-large : 绝对字体尺寸。根据对象字体进行调整。较大
xx-large : 绝对字体尺寸。根据对象字体进行调整。最大
larger : 相对字体尺寸。相对于父对像中字体尺寸进行相对增大。使用成比例的 em 单位计算
smaller : 相对字体尺寸。相对于父对像中字体尺寸进行相对减小。使用成比例的 em 单位计算
length : 百分数 | 由浮点数字和单位标识符组成的长度值,不可为负值。其百分比取值是基于父对象中字体的尺寸。
说明:
设置或检索对象中的字体尺寸。此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。
示例:
p { font-style: normal; }
p { font-size: 12px; }
p { font-size: 20%; }
font-size-adjust
语法:
font-size-adjust : none | number
取值:
none : 默认值。允许字体序列中每一字体遵守它的自己的尺寸
number : 为字体序列中所有字体强迫指定同一尺寸
说明:
设置或检索用于对象中文本的字体名称序列是否强制使用同一尺寸。
示例:
p { font-family: arial, courier; font-size-adjust: none; }
p { font-family: verdana, courier; font-size-adjust: .56; }
font-stretch
语法:
font-stretch : normal | narrower | wider | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
取值:
normal : 默认值。不应用拉伸变形
narrower : 使用比当前设置的值导致字体宽度更小的值
wider : 使用比当前设置的值导致字体宽度更大的值
说明:
设置或检索用于对象中文本的文字是否横向的拉伸变形。改变是相对于浏览器显示的字体的正常宽度的。
示例:
p { font-stretch: wider; }
p { font-stretch: ultra-expanded; }
font-style
语法:
font-style : normal | italic | oblique
取值:
normal : 默认值。正常的字体
italic : 斜体。对于没有斜体变量的特殊字体,将应用 oblique
oblique : 倾斜的字体
说明:
设置或检索对象中的字体样式。对于此属性的默认值来说,IE提供了预定义样式。但是你可以在浏览器菜单的 Internet 选项 中更改它。
此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。
示例:
p { font-style: normal; }
p { font-style: italic; }
p { font-style: oblique; }
font-weight
语法:font-weight : normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
取值:
normal : 默认值。正常的字体。相当于 400 。声明此值将取消之前任何设置
bold : 粗体。相当于 700 。也相当于 b 对象的作用
bolder : 比 normal >粗
lighter : 比 normal >细
100 : 字体至少像 200 那样细
200 : 字体至少像 100 那样粗,像 300 那样细
300 : 字体至少像 200 那样粗,像 400 那样细
400 : 相当于 normal
500 : 字体至少像 400 那样粗,像 600 那样细
600 : 字体至少像 500 那样粗,像 700 那样细
700 : 相当于 bold
800 : 字体至少像 700 那样粗,像 900 那样细
900 : 字体至少像 800 那样粗
说明:
设置或检索对象中的文本字体的粗细。作用由用户端系统安装的字体的特定字体变量映射决定。系统选择最近的匹配。也就是说,用户可能看不到不同值之间的差异。IE4.0仅仅支持 normal 和 bold 值。此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。
示例:
span { font-weight:800; }