Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[教程] 自编SupeSite_X-Space_V5风格制做教程.好东东不断添加中.

[复制链接]
 楼主| zhanglei700 发表于 2006-10-25 17:17:04 | 显示全部楼层

今天新发个css基础教程.转载于它人.

  1. 第一章 CSS基本语法

  2. CSS(Cascading Styel Sheet)是控制 Web 页面外观的一系列格式设置规则,是网页设计必不可少的工具之一。下面我们就开始学习css的基本语法格式。

  3. ---------------------------
  4. 一 CSS定义规则
  5. ---------------------------
  6. 层叠样式表是一个完全的纯文本文件,通常以“css”为扩展名作为单独的文件来使用,它的内容包含了一组告诉浏览器,如何安排与显示特定的html标签中内容的规则,CSS定义规则由三个部分构成:选择符,属性和属性的取值。语法如下:

  7. 语法: selector { property: value }
  8.        选择符   {   属性:    值  }

  9. 说明:

  10. 1 选择符

  11. 选择符是要定义样式的html标记,将html标记作为选择符定义后,则在html页面中该标记下的内容,会按照CSS定义的规则发生改变。

  12. 2 属性

  13. CSS属性指的是在选择符中要改变的内容,常见的有:字体属性,颜色属性,文本属性等。下面就是我们定义的一个样式表。

  14. @charset"gb2312";
  15. body {
  16.      font-family: "宋体";
  17.      font-size: 20px;
  18.      color: #FF0000;
  19. }
  20. p {
  21.      font-family: "宋体";
  22.      font-size: 30px;
  23.      color: #FF00ff;
  24. }

  25. 在这个样式表中:

  26. 1 @charset"gb2312";表示使用中文国标字符集。

  27. 2 body 和 p 是 html 中的两个标签,对这两个标签设置了三种样式,即:

  28. font-family: 指定字体的字型。

  29. font-size: 指定字体的大小。

  30. color: 指定字体的颜色。

  31. 上面我们定义了一个样式表,下一步的任务是如何把这个样式表和html文件相关联,使html文件按照我们定义的样式显示出来,与html文件相关联的方法有四种,下面我们分别叙述。



  32. ---------------------------
  33. 二 嵌入样式表
  34. ---------------------------

  35. 在Html页面内部定义的CSS样式表,叫做嵌入式CSS 样式表,也就是在HTML文档的head部分中,使用 style 标签并在该标签中定义一系列 CSS 规则。


  36. 语法:

  37. <head>
  38. <style type="text/css">
  39. <!--
  40. ......

  41. -->
  42. </style>
  43. </head>


  44. 说明:

  45. <style>指示CSS样式表开始,结束标志为 </style>,在开始标志 <style>中可以根据需要添加一些属性,如上列中的属性type="text/css",它表示CSS样式表采用MIME类型,这种类型的特点是,当浏览器不支持CSS代码时,对CSS代码进行过滤,避免浏览器以源代码的方式显示CSS代码。为了保证更加可靠,在样式表里再次加上注释标识符" <!--......-->",CSS规则就定义在这个注释标识符中。


  46. 示例1 [url=http://3dmax.9999mb.com/V5_css/t1.htm]t1.htm[/url]

  47. <html>
  48. <head>
  49. <meta http-equiv="Content-Type" content="text/html; charset= gb2312" />
  50. <title>嵌入式CSS样式表</title>
  51. <style type="text/css">
  52. <!--
  53. @charset"gb2312";
  54. body {
  55.      font-family: "宋体";
  56.      font-size: 20px;
  57.      color: #FF0000;
  58. }
  59. p {
  60.      font-family: "宋体";
  61.      font-size: 30px;
  62.      color: #FF00ff;
  63. }
  64. -->
  65. </style>
  66. </head>
  67. <body>
  68. 千山鸟飞绝万径人踪灭
  69. <p>
  70. 千山鸟飞绝万径人踪灭
  71. </p>

  72. </body>
  73. </html>



  74. ---------------------------
  75. 三 链接外部样式表
  76. ---------------------------

  77. 外部CSS样式表是一个以 .css为后缀的外部文件,定义一个外部样式表可以应用于多个页面。在html页面中使用link标签,可以将外部的css样式表连接进来,其语法如下:

  78. 语法:

  79. <link rel="stylesheet" href="*.css” type="text/css">

  80. 参数:

  81. 1 rel属性表示样式表将以何种方式与HTML文档结合。rel取值:Stylesheet,表示指定一个外部的样式表


  82. 2 *.css是单独保存的样式表文件。


  83. 示例2 定义一个外部css文件p2.css,然后在t2.htm文件中连接该文件。

  84. (1) 定义 p2.css

  85. @charset"gb2312";
  86. body {
  87.      font-family: "宋体";
  88.      font-size: 20px;
  89.      color: #FF0000;
  90. }
  91. p {
  92.      font-family: "宋体";
  93.      font-size: 30px;
  94.      color: #FF00ff;
  95. }


  96. (2) [url=http://3dmax.9999mb.com/V5_css/t2.htm]t2.htm [/url]

  97. <html>
  98. <head>
  99. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  100. <title>链接外部样式表</title>
  101. <link href="p2.css" rel="stylesheet" type="text/css">
  102. </head>
  103. <body>
  104. 亲爱的,你慢慢飞,小心前面带刺的玫瑰
  105. <p>
  106. 亲爱的,你张张嘴,风中花香会让你沉醉
  107. </p>
  108. </body>
  109. </html>


  110. ---------------------------
  111. 四 内联样式表
  112. ---------------------------

  113. 内联样式指的是,在HTML特定的标签中定义的CSS样式表。常用的HTML 标签主要是BODY中的一些元素,例如:<p>,<h2>,<ul>,<div>等,下面是内联样式的示例。

  114. 示例3 [url=http://3dmax.9999mb.com/V5_css/t3.htm]t3.htm[/url]

  115. <html>
  116. <head>
  117. <meta http-equiv="Content-Type" content="text/html; charset= gb2312" />
  118. <title>无标题文档</title>
  119. </head>
  120. <body>
  121. <div style="color:blue;font-size:30px ;">
  122. 风中花香会让你沉醉
  123. </div>
  124. <p style="color:#ff0000; font-style: italic; " >
  125. 风中花香会让你沉醉

  126. </p>
  127. </body>
  128. </html>


  129. ---------------------------
  130. 五 导入外部样式表
  131. ---------------------------

  132. 导入外部样式表指的是,在html文件中已经建立了嵌入式样式表,但是还要使用外部样式表的某些设置,这时就可以在<style>里导入一个外部样式表,导入时用@import,如下例所示。



  133. <html>
  134. <head>
  135. <style type="text/css">
  136. <!--
  137. @import url("mystyle.css");
  138. 其他样式表的声明
  139. -->
  140. </style>
  141. </head>
  142. </body>
  143. ......
  144. </body>
  145. </html>



  146. 其中@import url("mystyle.css"); 表示导入mystyle.css样式表,导入外部样式表必须在样式表的开始部分,在内部样式表的上面。



  147. [url=http://3dmax.9999mb.com/V5_css/t4.htm]示例4[/url]

  148. 定义一个外部css文件p4.css,然后在t4.htm文件中导入该文件。

  149. (1) 定义 p4.css

  150. @charset"gb2312";
  151. body {
  152.      font-family: "宋体";
  153.      font-size: 20px;
  154.      color: #FF0000;
  155. }


  156. (2) [url=http://3dmax.9999mb.com/V5_css/t4.htm]t4.htm [/url]

  157. <html>
  158. <head>
  159. <meta http-equiv="Content-Type" content="text/html; charset= gb2312" />
  160. <title>导入外部样式表</title>
  161. <style type="text/css">
  162. <!--
  163. @import url("p4.css");
  164. p {
  165. font-family: "宋体";
  166. font-size: 30px;
  167. color: #FF00ff;
  168. }
  169. -->
  170. </style>
  171. </head>
  172. <body>
  173. 千山鸟飞绝万径人踪灭
  174. <p>
  175. 千山鸟飞绝万径人踪灭
  176. </p>
  177. </body>
  178. </html>



  179. ---------------------------
  180. 六 css样式表的继承性
  181. ---------------------------

  182. 在css样式表中,子标签的某些属性会继承父标签的属性,例如标签p是标签body的子元素,当标签p未设置字体的颜色属性时,p中的内容会使用body中的颜色值,下面的示例说明了这种情况。

  183. 示例5 [url=http://3dmax.9999mb.com/V5_css/t5.htm]t5.htm [/url]

  184. <html>
  185. <head>
  186. <meta http-equiv="Content-Type" content="text/html; charset= gb2312" />
  187. <title>嵌入式CSS样式表</title>
  188. <style type="text/css">
  189. <!--
  190. @charset"gb2312";
  191. body {
  192.    font-family: "宋体";
  193.    font-size: 20px;
  194.    color: #FF0000;
  195. }
  196. p {
  197.    font-family: "宋体";
  198.    font-size: 30px;
  199. }
  200. -->
  201. </style>
  202. </head>
  203. <body>
  204. 千山鸟飞绝万径人踪灭
  205. <p>
  206. 千山鸟飞绝万径人踪灭
  207. </p>
  208. </body>
  209. </html>


  210. ---------------------------
  211. 七 设置多个元素
  212. ---------------------------

  213. css允许将单一的格式套用到多个标签,各个标签做为选择符时用逗号隔开,如下例所示。

  214. 示例6 [url=http://3dmax.9999mb.com/V5_css/t6.htm]t6.htm [/url]

  215. <html>
  216. <head>
  217. <meta http-equiv="Content-Type" content="text/html; charset= gb2312" />
  218. <title>嵌入式CSS样式表</title>
  219. <style type="text/css">
  220. <!--
  221. @charset"gb2312";
  222. h1,h2,h3,p,{
  223. font-family: "宋体";

  224. color: #FF0000;
  225. }
  226. -->
  227. </style>
  228. </head>
  229. <body>
  230. <h1>千山鸟飞绝万径人踪灭</h1>
  231. <h2>千山鸟飞绝万径人踪灭</h2>
  232. <h3>千山鸟飞绝万径人踪灭</h3>
  233. <p>千山鸟飞绝万径人踪灭</p>
  234. </body>
  235. </html>











复制代码

[ 本帖最后由 zhanglei700 于 2006-10-25 17:34 编辑 ]
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 17:18:05 | 显示全部楼层

第二章 字体的设置

  1. 第二章 字体的设置

  2. 在css中使用font属性集对字体的风格,大小,亮度等进行设置,下面我们开始学习它们。
  3. ---------------------------
  4. 一 字体风格 font-style
  5. ---------------------------

  6. font-style属性用于字体显示的风格。
  7. 语法:{font-style:inherit|italic|normal|oblique}
  8. 说明:
  9. (1)inherit 继承,表示该属性从父标签中继承而来。
  10. (2)italic  斜体,表示使用斜体显示文字。
  11. (3)normal  正常,为默认值。
  12. (4)oblique 偏斜体,表示有点倾斜但不大。


  13. 示例1 t1.htm

  14. <html>
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  17. <title>字体类型</title>
  18. <style type="text/css">
  19. <!--h1{
  20.   font-style: inherit;
  21. }
  22. h2{
  23.   font-style: italic;
  24. }
  25. h3{
  26.   font-style: normal;
  27. }
  28. p {
  29.   font-style: oblique;
  30. }
  31. -->
  32. </style>
  33. </head>
  34. <body>
  35. <h1>继承inherit</h1>
  36. <h2>斜体italic</h2>
  37. <h3>正常normal</h3>
  38. <p>偏斜体oblique</p>
  39. </body>
  40. </html>


  41. ---------------------------
  42. 二 字体变化 font-variant
  43. ---------------------------

  44. font-variant属性用于指定英文字体在打印时的大小对比。

  45. 语法:{font-variant:normal|small-caps|inherit}
  46. 说明:
  47. (1)normal 表示打印时大写字母没变化。
  48. (2)small-caps 表示打印时大写字母比通常小一点。
  49. (3)inherit 表示该属性从父标签中继承而来。


  50. 示例2 t2.htm

  51. <html>
  52. <head>
  53. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  54. <title>字体类型</title>
  55. <style type="text/css">
  56. <!--
  57. h1{
  58. font-variant:normal;
  59. }
  60. h2{
  61. font-variant:small-caps;
  62. }
  63. h3{
  64. font-variant:inherit;
  65. }
  66. -->
  67. </style>
  68. </head>
  69. <body>
  70. <h1>Normal表示打印时大写字母没变化</h1>
  71. <h2>Small-caps 表示打印时大写字母比通常小一点</h2>
  72. <h3>Inherit表示该属性从父标签中继承而来</h3>
  73. </body>
  74. </html>


  75. ---------------------------
  76. 三 字体亮度 font-weight
  77. ---------------------------

  78. 语法:{font-weight:100-900|bold|bolder|lighter|normal}
  79. 说明:浏览器默认的字体粗细为400。
  80. (1)bold 表示黑体字(相当于数值700 )
  81. (2)bolder 表示比黑体还要黑的字
  82. (3)lighter 表示比黑体颜色要浅
  83. (4)normal 正常体(相当于数值400)
  84. (5)可以指定100-900之间的3位整数,100表示最亮,400表示正常



  85. 示例3 t3.htm

  86. <html>
  87. <head>
  88. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  89. <title>字体类型</title>
  90. <style type="text/css">
  91. <!--
  92. h1{
  93. font-style: inherit;
  94. font-weight:lighter;
  95. }
  96. h2{
  97. font-style: italic;
  98. font-weight:bolder;
  99. }
  100. h3{
  101. font-style: normal;
  102. font-weight:bold;
  103. }
  104. p {
  105. font-style: oblique;
  106. font-weight:100;
  107. }
  108. -->
  109. </style>
  110. </head>
  111. <body>
  112. 未设置样式的字体:床前明月光,疑是地上霜。
  113. <h1>继承inherit,比黑体颜色要浅lighter</h1>
  114. <h2>斜体italic,比黑体还要黑bolder</h2>
  115. <h3>正常体normal,黑体字bold</h3>
  116. <p>偏斜体oblique,最亮100</p>
  117. </body>
  118. </html>



  119. ---------------------------
  120. 四 字体大小 font-size
  121. ---------------------------

  122. font-size属性用来指定字体的相对或绝对大小。

  123. 语法:{ font-size:数值|large| larger| x-large|small|smaller| x-smal ...}
  124. 说明:字体大小使用数值设置也可以使用比例

  125. (1)medium 标准字体大小
  126. (2)small 比父字体小一号的字
  127. (3)x-small 比small小1.2倍的字
  128. (4)xx-small 比x-small小1.2倍的字
  129. (5)large 比父字体大一号的字
  130. (6)x-large 比large大1.2倍的字
  131. (7)xx-large 比x-large大1.2倍的字
  132. (8)整数+"符号单位",符号单位有:象素px,点数pt,英寸in,毫米mm等
  133. (9)整数+%,表示当前字体大小是父字体大小的百分比



  134. 示例4 t4.htm

  135. <html>
  136. <head>
  137. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  138. <title>字体类型</title>
  139. <style type="text/css">
  140. <!--
  141. h1{
  142. font-style: inherit;
  143. font-weight:lighter;
  144. }
  145. h2{
  146. font-style: italic;
  147. font-weight:bolder;
  148. }
  149. h3{
  150. font-style: normal;
  151. font-weight:bold;
  152. font-size:20pt;
  153. }
  154. p {
  155. font-style: oblique;
  156. font-weight:100;
  157. font-size:medium;
  158. }
  159. -->
  160. </style>
  161. </head>
  162. <body>
  163. 未设置样式的字体:床前明月光,疑是地上霜。
  164. <h1>继承inherit,比黑体颜色要浅lighter</h1>
  165. <h2>斜体italic,比黑体还要黑bolder</h2>
  166. <h3>正常体normal,黑体字bold,大小20pt</h3>
  167. <p>偏斜体oblique,最亮100,标准大小medium</p>
  168. </body>
  169. </html>



  170. ---------------------------
  171. 五 字型设置 font-family
  172. ---------------------------

  173. 字体类型
  174. 语法:{ font-family:"字体1","字体2","字体3"; }
  175. 说明:
  176. (1) 当指定了字体类型时,浏览器将调用客户端字体
  177. (2 )当指定了多种字体时,浏览器会安顺序进行搜索,如果没有搜索到,就使用默认字体。

  178. 示例5 t5.htm

  179. <html>
  180. <head>
  181. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  182. <title>字体类型</title>
  183. <style type="text/css">
  184. <!--
  185. h1{
  186. font-style: inherit;
  187. font-weight:lighter;
  188. font-family:"楷体_gb2312";
  189. }
  190. h2{
  191. font-style: italic;
  192. font-weight:bolder;
  193. font-family:"宋体";
  194. }
  195. h3{
  196. font-style: normal;
  197. font-weight:bold;
  198. font-size:20pt;
  199. }
  200. p {
  201. font-style: oblique;
  202. font-weight:100;
  203. font-size:medium;
  204. }
  205. -->
  206. </style>
  207. </head>
  208. <body>
  209. 未设置样式的字体:床前明月光,疑是地上霜。
  210. <h1>
  211. 继承inherit,比黑体颜色要浅lighter<br>font-family:"楷体_gb2312"
  212. </h1>
  213. <h2>斜体italic,比黑体还要黑bolder</h2>
  214. <h3>正常体normal,黑体字bold,大小20pt</h3>
  215. <p>偏斜体oblique,最亮100,标准大小medium</p>
  216. </body>
  217. </html>


  218. ---------------------------
  219. 六 字体颜色 color
  220. ---------------------------

  221. 语法:{color: 数值}
  222. 作用:字体颜色
  223. 说明:颜色参数取值范围
  224. ·以RGB值表示 如:#ff0000
  225. ·以默认颜色的英文名称表示 如red

  226. 示例6 t6.htm

  227. <html>
  228. <head>
  229. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  230. <title>字体颜色</title>
  231. <style type="text/css">
  232. <!--
  233. h1{
  234.    font-style: inherit;
  235.    color:#ff0000;
  236. }
  237. -->
  238. </style>
  239. </head>
  240. <body>
  241. <h1>字体颜色color </h1>
  242. </body>
  243. </html>



  244. ---------------------------
  245. 七 复合属性设置 font
  246. ---------------------------

  247. 可以使用font参数对一个标签进行复合属性设置。

  248. 标签{font:italic 30pt 楷体_gb2312}

  249. 示例6 t7.htm

  250. <html>
  251. <head>
  252. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  253. <title>字体类型</title>
  254. <style type="text/css">
  255. <!--
  256. p {font:italic 30pt 楷体_gb2312}
  257. -->
  258. </style>
  259. </head>
  260. <body>
  261. 未设置样式的字体:床前明月光,疑是地上霜。
  262. <p>舉頭望明月,低頭思故鄉</p>
  263. </body>
  264. </html>







复制代码
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 17:18:52 | 显示全部楼层

第三章 定义背景

  1. 第三章 定义背景

  2. 1.背景颜色:background-color

  3. 语法:{background-color:数值}
  4. 说明:参数取值和颜色属性一样,如"#ff0000"

  5. 示例 s3-1.htm

  6. <html>
  7. <head>
  8. <style type="text/css">
  9. <!--
  10. @charset"gb2312";
  11. body { background-color:"#999999" }
  12. p {

  13. font-family: "宋体";
  14. font-size:30px;
  15. color:"#FF0000";
  16. }

  17. -->
  18. </style>
  19. </head>
  20. <body>
  21. 使用background-color设置了body的背景色
  22. <p>
  23. 千山鸟飞绝万径人踪灭
  24. </p>
  25. <p>&nbsp;</p>
  26. <p><a href="h-3.htm#n1">返回</a></p>
  27. </body>
  28. </html>



  29. 2.背景图案:background-image

  30. 语法:{background-image: url(URL)}
  31. 说明: URL就是背景图片的存放路径。

  32. 示例 s3-2.htm

  33. <html>
  34. <head>
  35. <style type="text/css">
  36. <!--
  37. @charset"gb2312";
  38. body{
  39. background-color:"#999999";
  40. background-image: url(b0024.gif);
  41. }
  42. p {

  43. font-family: "宋体";
  44. font-size:30px;
  45. color:"#FF0000";
  46. }

  47. -->
  48. </style>
  49. </head>
  50. <body>
  51. 为body设置背景色background-color
  52. <br>
  53. 为body插入图片background-image

  54. <p>
  55. 千山鸟飞绝万径人踪灭
  56. </p>
  57. <p>&nbsp;</p>
  58. <p><a href="h-3.htm#n1">返回</a></p>
  59. </body>
  60. </html>



  61. 3.图案重复:background-repeat

  62. 语法:{background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}
  63. 参数取值范围:
  64. ·inherit 继承
  65. ·no-repeat 不重复平铺背景图片
  66. ·repeat 使图片完全平铺,为默认值
  67. ·repeat-x 使图片只在水平方向上平铺
  68. ·repeat-y 使图片只在垂直方向上平铺


  69. 示例 s3-3.htm

  70. <html>
  71. <head>
  72. <style type="text/css">
  73. <!--
  74. @charset"gb2312";
  75. body{
  76. background-color:"#999999";
  77. background-image:url(b0024.gif);
  78. background-repeat:repeat-x ;
  79. }
  80. p {

  81. font-family: "宋体";
  82. font-size:30px;
  83. color:"#FF0000";
  84. }

  85. -->
  86. </style>
  87. </head>
  88. <body>
  89. 图案横向重复background-repeat:repeat-x
  90. <br>
  91. 图案没有重复background-repeat:no-repeat;
  92. <p>
  93. 千山鸟飞绝万径人踪灭
  94. </p>
  95. <p>&nbsp;</p>
  96. <p><a href="h-3.htm#n1">返回</a></p>
  97. </body>
  98. </html>




  99. 4.图案滚动:background-attachment

  100. 语法:{background-attachment:fixed|scroll}
  101. 参数:
  102. ·scroll 页面滚动时背景也滚动
  103. ·fixed:页面滚动时背景不滚动


  104. 示例 s3-4.htm

  105. <html>
  106. <head>
  107. <style type="text/css">
  108. <!--
  109. @charset"gb2312";
  110. body{
  111. background-color:"#999999";
  112. background-image:url(b0024.gif);
  113. background-repeat:repeat-x ;
  114. background-attachment:fixed;
  115. }
  116. p {

  117. font-family: "宋体";
  118. font-size:30px;
  119. color:"#FF0000";
  120. }

  121. -->
  122. </style>
  123. </head>
  124. <body>
  125. 背景图案不随页面滚动background-attachment:fixed;
  126. <br>
  127. 背景图案随页面滚动background-attachment:scroll;
  128. <p>
  129. 千山鸟飞绝万径人踪灭
  130. </p>
  131. <p>&nbsp;</p>
  132. <p><a href="h-3.htm#n1">返回</a></p>
  133. </body>
  134. </html>




  135. 5.图案定位:background-position

  136. 语法:{background-position:数值|top|bottom|left|right|center}
  137. 参数:
  138. ·top:顶对齐 background-position:top;
  139. ·bottom:底对齐 background-position:bottom;
  140. ·left:左对齐
  141. ·right:右对齐
  142. ·center:中心对齐
  143. ·绝对数值:background-position:200pt 100pt;
  144. ·相对比例:background-position:20% 70%;


  145. 示例 s3-5.htm

  146. <html>
  147. <head>
  148. <style type="text/css">
  149. <!--
  150. @charset"gb2312";
  151. body{
  152. background-color:"#999999";
  153. background-image:url(b0024.gif);
  154. background-repeat:no-repeat;
  155. background-attachment:fixed;
  156. background-position:20% 70%;
  157. }
  158. p {

  159. font-family: "宋体";
  160. font-size:30px;
  161. color:"#FF0000";
  162. }

  163. -->
  164. </style>
  165. </head>
  166. <body>
  167. 图案定位:background-position
  168. <p>
  169. 千山鸟飞绝万径人踪灭
  170. </p>
  171. <p>&nbsp;</p>
  172. <p><a href="h-3.htm#n1">返回</a></p>
  173. </body>
  174. </html>




  175. 示例 s3-6.htm

  176. <html>
  177. <head>
  178. <style type="text/css">
  179. <!--
  180. body{ background-color:"#999999";}
  181. p {

  182. background-image:url(b0024.gif);
  183. font-family: "宋体";
  184. font-size:30px;
  185. color: #FF00FF;
  186. }

  187. -->
  188. </style>
  189. </head>
  190. <body>
  191. 图案插入p标签中background-image
  192. <p>
  193. 千山鸟飞绝万径人踪灭
  194. </p>
  195. <p>&nbsp;</p>
  196. <p><a href="h-3.htm#n1">返回</a></p>
  197. </body>
  198. </html>











复制代码
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 17:19:28 | 显示全部楼层

第四章 边框设置

  1. 第四章 边框设置


  2. ===================================================
  3. 一 margin
  4. ===================================================
  5. margin属性用于设置边界边框,默认情况下margin属性没有继承性。

  6. 1 margin-top 指定顶部空白 margin-top:30pt;
  7. 2 margin-right 指定右端空白 margin-right:2%;
  8. 3 margin-bottom 指定底部空白 margin-bottom:auto;
  9. 4 margin-left 指定左端空白 margin-left:0;

  10. 注:auto-->自动指定
  11. 0-->表示没有空白,为默认值
  12. %-->表示相对于父级空白的百分比


  13. 示例4.1

  14. 本例设置p标签左侧缩进50px

  15. s1.htm

  16. <html>
  17. <head>
  18. <style type="text/css">
  19. <!--
  20. p {
  21. font-family: "宋体";
  22. font-size:30px;
  23. color: #FF00FF;
  24. margin-left:50px;
  25. }

  26. -->
  27. </style>
  28. </head>
  29. <body>
  30. <h2>千山鸟飞绝万径人踪灭</h2>
  31. <p>标签p中的元素左侧距离margin-left:50; </p>
  32. <p>margin属性具有定位作用</p>
  33. <p></p>
  34. </body>
  35. </html>




  36. 示例4.2

  37. 本例对p标签的四个边界设置了空白

  38. s2.htm

  39. <html>
  40. <head>
  41. <style type="text/css">
  42. <!--
  43. body{
  44. background-color:"#999999";
  45. }

  46. p {

  47. background-image:url(b0024.gif);
  48. font-family: "宋体";
  49. font-size:20px;
  50. color: #FF00FF;
  51. margin-top:30pt;
  52. margin-right:30pt;
  53. margin-left:30pt;
  54. margin-bottom:auto;
  55. }

  56. -->
  57. </style>
  58. </head>
  59. <body>
  60. <p>
  61. 千山鸟飞绝万径人踪灭
  62. </p>
  63. <p>底部边界由浏览器自动设置margin-bottom:auto;</p>
  64. <p><a href="h-3.htm#n1">返回</a></p>
  65. <p>&nbsp;</p>
  66. </body>
  67. </html>





  68. 示例4.3

  69. 本例对p标记的顶和左边界进行了设置

  70. (1)p3.css

  71. @charset"gb2312";
  72. p {
  73. margin-top:30pt;
  74. margin-left:30pt;
  75. font-family: "宋体";
  76. font-size: 20px;
  77. font-weight:100;
  78. color: #ff0000;
  79. background-color:"#d6ffd6" ;
  80. }



  81. (2)s3.htm


  82. <html>
  83. <head>
  84. <title>链接外部样式表</title>
  85. <link href="p3.css" rel="stylesheet" type="text/css">
  86. </head>
  87. <body>
  88. <p>
  89. margin-top 指定顶部空白
  90. </p>
  91. <p>
  92. margin-bottom 指定底部空白
  93. </p>
  94. <p>
  95. margin用来设置最外层的空白区域
  96. </p>
  97. </body>
  98. </html>


  99. ===================================================
  100. 二 border
  101. ===================================================
  102. border属性用于设置边框样式,颜色,空白缩进等。

  103. 1 border-left 设置左边框
  104. 2 border-right 设置右边框
  105. 3 border-bottom 设置底边框
  106. 4 border-top 设置顶边框
  107. 5 border-color 设置边框颜色
  108. 6 border-style 设置边框风格
  109. (1)none 忽略边框
  110. (2)hidden 隐藏边框
  111. (3)dotted 边框使用点滑线
  112. (4)dashed 边框使用短线
  113. (5)solid 边框使用实线
  114. (6)double 边框使用双实线
  115. (7)groove 边框使用三维凹线
  116. (8)ridge 边框使用三维凸线
  117. (9)inset 边框使用内三维线,结合背景构造凹陷按钮
  118. (10)outset 边框使用外三维线,结合背景构造凸出按钮
  119. (11)inherit 从父级继承
  120. 7 border-width 设置边框宽度
  121. ()medium 默认中等宽度
  122. ()thin 比默认略窄
  123. ()thick 比默认略宽
  124. ()inherit 从父级继承
  125. 注:只有设置了style属性才可以设置width。


  126. 示例4.4

  127. 本例对p标记设置了实线边框

  128. (1)p4.css

  129. @charset"gb2312";
  130. p{
  131. margin-right:50pt;
  132. margin-left:50pt;
  133. border-style:solid;
  134. border-color:"red";
  135. background-color:"#d6ffd6";
  136. }


  137. (2)s4.htm

  138. <html>
  139. <head>
  140. <title>链接外部样式表</title>
  141. <link href="p4.css" rel="stylesheet" type="text/css">
  142. </head>
  143. <body>
  144. <p>边框使用实线border-style:solid;</p>
  145. <p>边框颜色border-color:"red";</p>
  146. <p>边框背景background-color:"#d6ffd6"; </p>
  147. </body>
  148. </html>



  149. 示例4.5

  150. 本例对p标记的四个边框分别设置

  151. (1)p5.css

  152. @charset"gb2312";
  153. p{
  154. margin-right:50pt;
  155. margin-left:50pt;
  156. border-left-style:solid;
  157. border-right-style:double;
  158. border-top-style:dotted;
  159. border-bottom-style:dashed;
  160. border-color:"red";
  161. background-color:"#d6ffd6";
  162. }


  163. (2)s5.htm

  164. <html>
  165. <head>
  166. <title>链接外部样式表</title>
  167. <link href="p5.css" rel="stylesheet" type="text/css">
  168. </head>
  169. <body>
  170. <p>左边框border-left-style:solid;</p>
  171. <p>右边框border-right-style:double;</p>
  172. <p>顶边框border-top-style:dotted;</p>
  173. <p>
  174. 下边框border-bottom-style:dashed;<br>
  175. 边框颜色border-color:"red";<br>
  176. 背景颜色background-color:"#d6ffd6";
  177. </p>
  178. </body>
  179. </html>





  180. 示例4.6

  181. (1)p6.css

  182. @charset"gb2312";

  183. body{background-color: #ECE9E8;}

  184. h1{
  185. margin-right:50pt;
  186. margin-left:50pt;
  187. border-style:outset;
  188. background-color:"#C0C0C0";
  189. border-width:thick;
  190. }

  191. h2{
  192. margin-right:50pt;
  193. margin-left:50pt;
  194. border-style:groove;
  195. background-color:"#C0C0C0";
  196. border-width:thick;
  197. }

  198. h3{
  199. margin-right:50pt;
  200. margin-left:50pt;
  201. border-style:ridge;
  202. background-color:"#C0C0C0";
  203. border-width:thick;
  204. }

  205. p{
  206. margin-right:50pt;
  207. margin-left:50pt;
  208. border-style:groove;
  209. background-color:"#D3D3D3";
  210. border-width:thick;
  211. border-color:"#999999"
  212. }






  213. (2)s6.htm

  214. <html>
  215. <head>
  216. <title>链接外部样式表</title>
  217. <link href="p6.css" rel="stylesheet" type="text/css">
  218. </head>
  219. <body>
  220. <h1>外三维线outset</h1>
  221. <h2>内三维线inset</h2>
  222. <h3>三维凸线ridge</h3>
  223. <p>
  224. 三维凹线groove
  225. </p>
  226. </body>
  227. </html>









复制代码
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 17:20:00 | 显示全部楼层

第五章 边框内容设置

  1. 第五章 边框内容设置


  2. ==============================================
  3. 一 padding
  4. ==============================================
  5. padding用来设置边框中的内容,在没有设置padding属性时,放在边框内的元素都是紧贴边框的。

  6. 1 padding-top 顶边距
  7. 2 padding-bottom 底边距
  8. 3 padding-left 左边距
  9. 4 padding-right 右边距

  10. 上面四个属性的设置和前面的类似,既可以设置绝对值也可以相对,例如。

  11. padding-top:3px;
  12. padding-bottom:5%;



  13. 示例5.1

  14. (1)css5-1.css

  15. @charset"gb2312";

  16. body{background-color: #ECE9E8;}
  17. h1{
  18. margin-right:50pt;
  19. margin-left:50pt;
  20. border-style:outset;
  21. background-color:"#C0C0C0";
  22. border-width:thick;
  23. padding-top:8px;
  24. padding-bottom:5px;
  25. padding-left:8px;
  26. }

  27. h2{
  28. margin-right:50pt;
  29. margin-left:50pt;
  30. border-style:inset;
  31. background-color:"#C0C0C0";
  32. border-width:thick;

  33. }


  34. (2)htm5-1.htm

  35. <html>
  36. <head>
  37. <title>链接外部样式表</title>
  38. <link href="css5-1.css" rel="stylesheet" type="text/css">
  39. </head>
  40. <body>
  41. <h1>外三维线outset,内容与边框设置一点距离</h1>
  42. <h2>内三维线inset,内容紧贴边框</h2>
  43. <p>

  44. </p>
  45. </body>
  46. </html>

  47. ==============================================
  48. 二 文本设置
  49. ==============================================

  50. 1 text-align
  51. 用来设置文本水平对齐的方式
  52. (1)text-align:center;居中
  53. (2)text-align:left;左对齐
  54. (3)text-align:right;右对齐
  55. (4)text-align:inherit;继承

  56. 2 text-decoration
  57. 用来设置文本的强调方式
  58. (1)text-decoration:none;不指定文本效果
  59. (2)text-decoration:underline;下划线
  60. (3)text-decoration:through;中划线
  61. (4)text-decoration:overline;上划线
  62. (5)text-decoration:blink;文本闪烁
  63. (6)text-decoration:inherit;继承

  64. 3 text-indent
  65. 用来设置首行缩进
  66. (1)text-indent:3pt;绝对值
  67. (2)text-indent:3%;相对值
  68. (3)text-indent:inherit;继承

  69. 4 text-transform
  70. 用来设置大小写转换
  71. (1)text-transform:capitalize;首字母大写
  72. (2)text-transform:uppercase;所有字母大写
  73. (3)text-transform:lowercase;全部小写
  74. (4)text-transform:none;不使用大小写转换,为默认
  75. (5)text-transform:inherit;继承


  76. 示例5.2

  77. (1)css5-2.css

  78. @charset"gb2312";
  79. p{
  80. margin-right:50pt;
  81. margin-left:50pt;
  82. background-color:"#C0C0C0";
  83. border-width:thick;
  84. padding-top:5px;
  85. padding-bottom:5px;
  86. padding-left:5px;

  87. text-indent:40px;

  88. }
  89. h2{
  90. margin-right:50pt;
  91. margin-left:50pt;
  92. border-style:outset;
  93. background-color:"#C0C0C0";
  94. border-width:thick;

  95. text-align:center;
  96. }

  97. (2)htm5-2.htm

  98. <html>
  99. <head>
  100. <title>链接外部样式表</title>
  101. <link href="css5-2.css" rel="stylesheet" type="text/css">
  102. </head>
  103. <body>
  104. <h2>床前明月光,疑是地上霜<br>
  105. 舉頭望明月,低頭思故鄉
  106. </h2>
  107. <p>
  108. 千岛湖,是1959年9月新安江水力发电站拦河大坝建成后,截蓄新安江水流而成的巨大水库。据淳安县地名委员会1983年普查结果,水库淹没85座山,形成大小岛屿1078座(按设计水位108米高程,面积2500平方米为极限计算),故名“千岛湖”。
  109. </p>
  110. </body>
  111. </html>



  112. ==============================================
  113. 三 字间距设置
  114. ==============================================

  115. 1 word-spacing
  116. 用来设置单词之间的距离,仅对英文有效。
  117. (1)word-spacing:normal;正常值
  118. (2)word-spacing:3pt;绝对值
  119. (3)word-spacing:inherit;继承


  120. 2 letter-spacing
  121. 用来设置字符的间距
  122. (1)letter-spacing:normal;正常值
  123. (2)letter-spacing:3pt;绝对值
  124. (3)letter-spacing:inherit;继承




  125. (1)css5-3.css

  126. @charset"gb2312";
  127. p{
  128. margin-right:50pt;
  129. margin-left:50pt;
  130. background-color:"#C0C0C0";
  131. border-width:thick;
  132. padding-top:5px;
  133. padding-bottom:5px;
  134. padding-left:5px;
  135. text-indent:40px;

  136. word-spacing:10pt;
  137. }

  138. (2)htm5-3.htm

  139. <html>
  140. <head>
  141. <title>链接外部样式表</title>
  142. <link href="css5-3.css" rel="stylesheet" type="text/css">
  143. </head>
  144. <body>
  145. <h2>床前明月光,疑是地上霜<br>
  146. 舉頭望明月,低頭思故鄉
  147. </h2>
  148. <p>
  149. 千岛湖,是1959年9月新安江水力发电站拦河大坝建成后,截蓄新安江水流而成的巨大水库。据淳安县地名委员会1983年普查结果,水库淹没85座山,形成大小岛屿1078座(按设计水位108米高程,面积2500平方米为极限计算),故名“千岛湖”。
  150. </p>
  151. </body>
  152. </html>







复制代码
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 17:20:32 | 显示全部楼层

第六章 class与ID

  1. 第六章 class与ID

  2. class与ID主要用来对相同的标签进行不同的设置和对不同的标签进行相同的设置。

  3. ==============================================
  4. 一 class
  5. ==============================================
  6. class通常叫做类选择符,

  7. 语法:

  8. 1 定义类

  9. (1)带标签定义


  10. 语法:选择符.标识符{ 选择符样式定义 }

  11. (2)不带标签定义


  12. 语法:.标识符{ 选择符样式定义 }

  13. 2 引用类

  14. <选择符 class="标识符">......</选择符>


  15. 示例6-1

  16. (1)css6-1.css

  17. @charset"gb2312";
  18. p.A{
  19. font-size:20pt;
  20. color:#ff0000;
  21. }
  22. p.B{
  23. font-size:20pt;
  24. color:#0000ff;
  25. }
  26. .AB{
  27. font-size:20pt;
  28. color:#ff00ff;
  29. }

  30. (2)htm6-1.htm

  31. <html>
  32. <head>
  33. <title>链接外部样式表</title>
  34. <link href="css6-1.css" rel="stylesheet" type="text/css">
  35. </head>
  36. <body>
  37. <p class="A">床前明月光,疑是地上霜</p>
  38. <p class="B">舉頭望明月,低頭思故鄉</p>
  39. <h1 class="AB">床前明月光,疑是地上霜</h1>
  40. <h2 class="AB">床前明月光,疑是地上霜</h2>
  41. <p class="AB">床前明月光,疑是地上霜</p>
  42. </body>
  43. </html>


  44. ==============================================
  45. 一 ID
  46. ==============================================


  47. 1 定义ID

  48. 语法:#标识符{ 样式定义 }

  49. 2 引用

  50. 语法:<选择符 ID="标识符">......</选择符>



  51. 示例6-2

  52. (1) css6-2.css

  53. @charset"gb2312";
  54. #A1{
  55. font-size:20pt;
  56. color:#ff0000;
  57. }
  58. #A2{
  59. font-size:20pt;
  60. color:#0000ff;
  61. }
  62. #A3{
  63. font-size:20pt;
  64. color:#ff00ff;
  65. }



  66. (2) htm6-2.htm

  67. <html>
  68. <head>
  69. <title>链接外部样式表</title>
  70. <link href="css6-2.css" rel="stylesheet" type="text/css">
  71. </head>
  72. <body>
  73. <p ID="A1">床前明月光,疑是地上霜</p>
  74. <p ID="A2">舉頭望明月,低頭思故鄉</p>
  75. <h1 ID="A1">床前明月光,疑是地上霜</h1>
  76. <h1 ID="A2">床前明月光,疑是地上霜</h1>
  77. <h1 ID="A3">床前明月光,疑是地上霜</h1>
  78. </body>
  79. </html>















复制代码
回复

使用道具 举报

ejykluang 发表于 2006-10-25 18:03:56 | 显示全部楼层
不好意思.你指的是不是

论坛管理>论坛设置>编辑论坛...

我已经把它钩了,可是还是一样.请指点
help3.jpg
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 19:12:26 | 显示全部楼层
原帖由 ejykluang 于 2006-10-25 18:03 发表
不好意思.你指的是不是

论坛管理>论坛设置>编辑论坛...

我已经把它钩了,可是还是一样.请指点

论坛先更新缓存.再在ss后台设置。再更新,如果启用了HTML  .就要删除才能看到.
要是还没有.请教于茄子妹妹.
Capture265.jpg
回复

使用道具 举报

 楼主| zhanglei700 发表于 2006-10-25 19:15:46 | 显示全部楼层
1111111111111111111
Capture266.jpg
回复

使用道具 举报

ejykluang 发表于 2006-10-26 15:26:15 | 显示全部楼层
小弟又有问题想请问要如何制作图例的Flash幻灯片?

是不是跟着https://discuz.dismall.com/viewthread.php?tid=415961&extra=&page=20的代码?
help4.jpg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-27 03:58 , Processed in 0.152983 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表