(1)字体的设置font-family:"GillSans"
,中间用空格分开。
select
、textarea
、input
需要强制继承input,select,input{font-family:inherit}
。设定首选字体,替代字体。字体列表为字体栈(font-stack)。
windows
与os x
上默认共有的字体有:arial
,comic Sans MS
,Courier New
,Georgia
,Impact
、Trebuchet MS
,Time New Roman
和Verdana
。此外还可使用Web
字体。
(2) font-style:italic
设置斜体,font-style:normal
取消斜体,font-weight:bold\(100-900)
设置粗体,font-normal
取消粗体,font-weight
属性是继承性的,font-size:px或em(相对于父元素文本的大小)
设置字体大小,body
上设置基准font-size:100
约为16px
大小,rem
以根元素为参照系设置其他元素字体的大小,font-size
属性也是继承的。line-height:n
设置行高为n乘字体的大小。可通过简写属性同时设置所有字体值,body{font:100% Geneva, Tahoma, Verdana, sans-serif}
。
(3)color
设置字体颜色,可对几个段落、几个单词、不同状态的链接、内容区域等修改背景,background-color:#88b2d2
,设置颜色背景,background-image:url(image.png)
设置图片背景image.png
是图片想对于样式表所在的路径和文件名,background-repeat:repeat/repeat-x/repeat-y/no-repeat
设置背景图像是否重复,background-attachment:fixed/scoll/local
设置背景图像是否随页面滚动,background-position: left bottom
指定元素背景图像的位置,body{background:#004 url(../image.png) no-repeat 170px 20px color:green}
背景的简记法,设置多有的属性。
(4) 单词之间的距离叫字间距(tracking
)用word-spacing
设置,字母之间的距离称为字偶距离(kerning
)用letter-spacing
设置,两者皆为继承属性。text-indent
设置段落第一行缩进。text-align
设置文本对齐方式,其值有justy
(两端对齐)、center
等。text-transform
,为样式定义文本的大小写,其值可取为uppercase
、lowercase
、none
、capitalize
。font-variant
设置小型大写字母变体,即其中的一些字母是大写的但缩小到了小写字母的大小,其值取为small-caps
等。
(5)text-decoration
属性装饰文本,其值有underline
、overline
、line-through
及取消文本装饰的none
。white-spacing
设置空白属性,pre
显示原文中的所有空格,nowrap
确保所有空格不断行,normal
正常处理。