日期:2013-09-29  浏览次数:20999 次

七.CSS1属性

3.1  font属性

       字模、字体款式、字体大小、字体效果等。常用属性有:

① font-family:字模,Cursive、Fantasy、Comic Sans MS等。

② font-size:字体物理大小或绝对大小,物理大小包括:xx-small、x-small、small、medium、large、x-large、xx-large分别对应1~7号字体。

③ font-style:能否斜体, normal、italic、oblique(=italic)。

④ font-weight:文字粗细,normal、bold、bolder、lighter。

⑤ font-variant:小型大写字母,normal、small-caps(小型大写字母)。

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[endif]-->3.2  text属性

       文本修饰、文本缩进、单词间距、字母间距、行间距、文本的水平对齐和垂直对齐以及空白大小的控制。常用属性有:

① text-transform:单词大小写,none、capitalize、uppercase、lowercase。

② text-decoration:特殊效果,none、line-through、overline、underline。

③ word-spacing:单词间距,normal、英寸(in)、厘米(cm)、point(pt)、pica(pc)、em(em)、像素(px)。

④ letter-spacing:字母间距。

⑤ vertical-align:文本或图像的垂直定位,baseline(默认)、sub、super、top、text-top、middle、bottom、text-bottom。

⑥ text-align:文本水平对齐方式,left、right、center、justify。

⑦ text-indent:为段落元素第一行产生缩进。

⑧ line-height:当前行的高度,这样设置的行上下会空出相反的距离。

⑨ white-space:控制元素内空格的处理方式,normal(默认)、pre(不紧缩空格)、nowrap(即便文本行超出了元素内容的宽度也不会换行)

<!--[if !supportEmptyParas]--> <!--[endif]-->

3.3  color属性和background属性

① color:文字颜色

② background-color:背景色

③ background-image:背景图像,背景色显示在背景图像的下面,以提供不通明的背景,比④ background-repeat:决定当背景图像比元素的画布空间小时该如何陈列。

repeat:默认,在水平和垂直两个方向上平铺;

repeat-x:仅在水平方向平铺;

repeat-y:仅在垂直方向平铺;

no-repeat:不平铺。

⑤ background-attachment:

scroll:默认,图像和文本一同滚动;

fixed:图像不动,水印效果。

⑥ background-position:背景图像在元素画布空间中的定位方式,指定了图像左上角绝对于画布的水平间距和垂直间距。可以用绝对距离(像素)、百分比或特殊关键字。

水平方向关键字:left、center、right

垂直方向关键字:top、center、bottom

<!--[if !supportEmptyParas]--> <!--[endif]-->

举例:background-image属性使用。

b{background-image:url(donut-tile.gif);background-color:white;}

p{background-image:url(picture.gif);background-position:20%  40%;}

body{background-image:url(picture.gif);background-position:center  center;}

<!--[if !supportEmptyParas]--> <!--[endif]-->

3.4  box属性

       像<p>元素这样的块级元素可以作为屏幕上的一个矩描述器来考虑。可以通过款式属性来控制这些容器的三个方面。可以控制的box属性如下:

① margin属性:决定元素的box的边和相邻元素的边的距离。

② border属性:决定包围元素的边的边框的视觉特性。

③ padding属性:决定元素内它的边和它的实际内容间的距离。

④ height,width和positioning属性:决定由元素产生的box的大小和位置。

<!--[if !supportEmptyParas]--> <!--[endif]-->

3.4.1  margin属性

       单边距的设置规则: