1 / 15

CSS 2

CSS 2. 袁磊 2005 年 5 月. 定义方法. 重新定义标签 调用方法:引用标签 # 调用方法: id * 调用方法: class Class 方法的应用: 定义: p.s1{color:green} p.s2{color:gray} 使用: <h1 class=s1> 内容 </h1>. Class Selector.

leanna
Télécharger la présentation

CSS 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSS 2 袁磊 2005年5月

  2. 定义方法 • 重新定义标签 调用方法:引用标签 • # 调用方法:id • * 调用方法:class Class方法的应用: 定义:p.s1{color:green} p.s2{color:gray} 使用:<h1 class=s1> 内容 </h1>

  3. Class Selector 利用Class Selector,你可以用同样的HTML Tag构成不同的样式。比如说,你希望段落<p>有两种样式,一种是居中对齐,一种是居右对齐。你就可以写如下样式: p.right {text-align:right}p.center {text-align:center}

  4. 更通用的写法 你也可以不用HTML Tag,直接用.加上Class名称作为一个Selector。示例代码如下: .center {text-align: center} 这种通用的Class Selector就没有Tag的局限性,可以用于不同的Tag。比如: <h1 class = "center">这个标题居中显示。</h1><p class = "center">这个段落居中显示。</p>

  5. 文本对齐属性(text-align) 这个属性用来设定文本的对齐方式。有以下值: left (居左,缺省值) right (居右) center (居中) justify (两端对齐) 示例代码如下: .p2 {text-align:right}

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

  7. 文本缩进属性(text-indent) 这个属性设定文本首行缩进。其值有以下设定方法: length (长度,可以用绝对单位(cm, mm, in, pt, pc)或者相对单位 (em, ex, px)) percentage (百分比,相当于父对象宽度的百分比) 示例代码如下: .p1 {text-indent: 8mm}

  8. 行高属性(line-height) 这个属性设定每行之间的距离。其值有以下设定方法: normal (缺省值) length (长度,可以用绝对单位(cm, mm, in, pt,pc)或者相对单位 (em, ex, px)) percentage (百分比,相当于父对象高度的百分比) 示例代码如下: .p1 {line-height:1cm}

  9. 颜色属性(color) 用颜色属性(color)可以改变文本的字体颜色。示例代码如下: .p1{color:gray}

  10. 字间距属性(letter-spacing) 这个属性用来设定字符之间的距离。 normal (缺省值) length (长度,可以用绝对单位(cm, mm, in, pt, pc)或者相对单位 (em, ex, px)) 示例代码如下: .p1 {letter-spacing: 3mm}

  11. 调用方法1:直接调用 <h1 style="font-family:楷体; color:red">

  12. 内部css <html> <head> <title>对HTML标记直接定义</title> <style type="text/css"> h1 {font-family:楷体; color:yellow} h2 {font-family:黑体; color:blue} </style> </head> <body> <font> <p><h1>此行文字为黄色楷体的字体</h1> <p><h2>此行文字为蓝色黑体的字体</h2> </font> </body> </html>

  13. link <head>  <link type=”text/css” rel=”stylesheet” href=”*.css” media=”screen”>  </head>   在一个页面中引入一个外部的css使用

  14. @Import(倒入) <style type="text/css"> @import url(“1.css”); </style> 在一个页面中引入一个外部的css使用

  15. 作业 • 自己建一个css文件,并在html中调用这个css文件中的样式。

More Related