当前位置:文档之家› 字体和常用文本和背景属性

字体和常用文本和背景属性

字体和常用文本和背景属性CSS字体属性字体名称属性(font-family)这个属性设定字体名称,如Arial, Tahoma, Courier等。

例句如下:.s1 {font-family:Arial}<html><head><title>字体名称属性font-family</title><STYLE>.s1 {font-family:Arial}.s2 {font-family:Tahoma}.s3 {font-family:Courier}.s4 {font-family:Verdana}.s5 {font-family:"Book Antiqua"}</STYLE></head><body><p>The font-family value of the text is the browser default font.</p><p class = "s1">The fon-family value of the text is "Arial"。

</p><p class = "s2">The fon-family value of the text is "Tahoma"。

</</p><p class = "s3">The fon-family value of the text is "Courer"。

</</p><p class = "s4">The fon-family value of the text is "Verdana"。

</</p><p class = "s5">The fon-family value of the text is "Book Antiqua"。

</</p></body></html>The font-family value of the text is the browser default font.The fon-family value of the text is "Arial"。

The fon-family value of the text is "Tahoma"。

The fon-family value of the text is "Courer"。

The fon-family value of the text is "Verdana"。

The fon-family value of the text is "Book Antiqua"。

字体大小属性(font-size)这个属性可以设置字体的大小。

字体大小的设置可以有多种方式,最常用的就是pt和px(pixel)。

例句如下:.s2 {font-size:16pt}<html><head><title>字体大小属性font-size</title><STYLE>BODY{font-size:10pt}.s1 {font-size:16px}.s2 {font-size:16pt}.s3 {font-size:80%}.s4 {font-size:larger}.s5 {font-size:xx-large}</STYLE></head><body><p>这段文字大小是10pt。

</p><p class = "s1">这段文字大小是16px。

</p><p class = "s2">这段文字大小是16pt。

</p><p class = "s3">这段文字大小是10pt的80%。

</p><p class = "s4">这段文字的大小比10pt大。

</p> <p class = "s5">这段文字的大小是特大号(xx-large)。

</p></body></html>这段文字大小是10pt。

这段文字大小是16px。

这段文字大小是16pt。

这段文字大小是10pt的80%。

这段文字的大小比10pt大。

这段文字的大小是特大号(xx-large)。

字体浓淡属性(font-weight)这个属性常用值是normal和bold,normal 是缺省值。

例句如下:<p style = "font-weight:bold">这段文字字体的浓淡属性(font-weight)值是bold。

<p><html><head><title>字体浓淡属性font-weight</title></head><body><p>这段文字没有设浓淡属性。

<p><p style = "font-weight:bold">这段文字字体的浓淡属性(font-weight)值是bold。

<p><p style = "font-weight:lighter">这段文字字体的浓淡属性(font-weight)值是lighter。

<p><p style = "font-weight:200">这段文字字体的浓淡属性值(font-weight)是200。

<p><p style = "font-weight:800">这段文字字体的浓淡属性值(font-weight)是800。

<p></body></html>字体变量属性(font-variant)这个属性有两个值,normal和small-caps,normal是缺省值。

small-caps表示小的大写字体。

例句如下:.s1 {font-variant:small-caps}字体属性(font)这个属性是各种字体属性的一种快捷的综合写法。

这个属性可以综合字体风格属性(font-style),字体变量属性(font-variant),字体浓淡属性(font-weight),字体大小属性(font-size)等属性。

例句如下:.s1 {font:italic normal bold 11pt arial}字体颜色(color)字体颜色用CSS中的color属性来表示。

参见CSS常用文本属性。

CSS常用文本属性文本对齐属性(text-align)这个属性用来设定文本的对齐方式。

有以下值:•left (居左,缺省值)•right (居右)•center (居中)•justify (两端对齐)示例代码如下:.p2 {text-align:right}<html><head><title>文本对齐属性text-align</title><style type="text/css">.p1{text-align:left}.p2 {text-align:right}.p3{text-align:center}</style></head><body><p class = "p1">这段的本文对齐属性(text-align)值为居左。

</p><p class = "p2">这段的本文对齐属性(text-align)值为居右。

</p><p class = "p3">这段的本文对齐属性(text-align)值为居中。

</p></body></html>文本修饰属性(text-decoration)这个属性主要设定文本划线的属性。

有以下值:•none (无,缺省值)•underline (下划线)•overline (上划线)•line-through (当中划线)示例代码如下:.p2 {text-decoration: underline}文本修饰属性(text-decoration)的缺省值是none。

这段的文本修饰属性(text-decoration)值是underline。

这段的文本修饰属性(text-decoration)值是line-through。

这段的文本修饰属性(text-decoration)值是overline。

文本缩进属性(text-indent)这个属性设定文本首行缩进。

其值有以下设定方法:•length (长度,可以用绝对单位(cm, mm, in, pt, pc)或者相对单位(em, ex, px))•percentage (百分比,相当于父对象宽度的百分比)示例代码如下:.p1 {text-indent: 8mm}<html><head><title>文本缩进属性text-indent</title><style type="text/css">.p1 {text-indent: 8mm}.d1 {width:300px}.p2 {text-indent:50%}</style></head><body><p>下面两端都设定CSS文本缩进属性(text-indent),第一段用长度方法设值,第二段用百分比方法设值。

</p><p class = "p1">芙蓉姐姐说道:“我那妖媚性感的外形和冰清玉洁的气质让我无论走到哪里都会被众人的目光无情地揪出来。

相关主题