CSS技术

CSS全称Cascading Style Sheet。层叠式样式表。

一、CSS的四种实现方式:

1.内嵌式:
<style type="text/css">
<!--
CSS代码段
-->
</style>

2.外链式:
<link href="*.css" rel="stylesheet" type="text/css">

3.导入式
<style type="text/css">
<!--
@import url("*.css");
-->
</style>

3.属性式:
<div style="position:absolute; width:200px; height:115px; z-index:1; left: 209px; top: 154px;"></div>


二.CSS的定义:
选择对象{属性1:值1;属性2:值2;属性3:值3;属性n:值n……}
如:
td{font-size:12px;color:#FFFF00}
.myname{font-size:12px;color:#FFFF00}
a:hover{font-size:12px;color:#FFFF00;text-decoration: underline;}


三.四种选择对象

1.HTML selector (TagName)
2.class selector (.NAME)
3.ID selector (#IDname)
4.特殊对象 (a:hover a:link a:visited a:active)


1.HTML selector
HTML selector就是HTML的置标符,如:DIV、TD、H1。HTML selector的作用范围是应用了该样式的所有页面中的所有该置标符。

例:
<html>
<head>
<title>艺网CSS教程 作者:木子李</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td
{
color: #FF0000;

-->
</style>
</head>
<body>
<table width="300" border="0">
  <tr>
    <td>艺网--ArtHtml.com</td>
  </tr>
  <tr>
    <td>探索民族设计风格 网聚全球艺术精华</td>
  </tr>
</table>
</body>
</html>

注意:在<TD>中没有应用什么,其中文字自动变红色。

2.class selector
定义class selector需要往其名称其加一个点“.”。如“.classname”。class selector的作用范围是所有包含“class="classname"”的置标符。

例:
<html>
<head>
<title>艺网CSS教程 作者:木子李</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.fontRed
{
color: #FF0000;
}
-->
</style>
</head>
<body>
<table width="300" border="0">
  <tr>
    <td class="fontRed">艺网--ArtHtml.com</td>
  </tr>
  <tr>
    <td>探索民族设计风格 网聚全球艺术精华</td>
  </tr>
</table>
</body>
</html>

注意:在第二个<TD>中没有“class="fontRed"”,所以文字没有变红色。

3.ID selector
定义ID selector需要往其名称其加一个点“#”。如“#IDname”。ID selector的作用范围是所有包含“ID="classname"”的置标符。

例:
<html>
<head>
<title>艺网CSS教程 作者:木子李</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
#fontRed
{
color: #FF0000;
}
-->
</style>
</head>
<body>
<table width="300" border="0">
  <tr>
    <td ID="fontRed">艺网--ArtHtml.com</td>
  </tr>
  <tr>
    <td>探索民族设计风格 网聚全球艺术精华</td>
  </tr>
</table>
</body>
</html>

注意:在第二个<TD>中没有“ID="fontRed"”,所以文字没有变红色。

4.特殊对象
特殊对象包括四种,是针对链接对象设置的:
a:hover 鼠标移上时的超链接
a:link 常规,非访问超链接
a:visited 访问过的超链接
a:active 鼠标点击时的超链接

特殊对象的作用范围是所有<a>置标符(这句话有待商榷,因为下面很快就有一种方法可以把“所有”两个字推翻)。

例:
<html>
<head>
<title>艺网CSS教程 作者:木子李</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a
{
color: #FF0000;
}
a:hover
{
color: #0000FF;
text-decoration: underline;
}
-->
</style>
</head>
<body>
<table width="300" border="0">
  <tr>
    <td><a href="http://www.ArtHtml.com">艺网--ArtHtml.com</a></td>
  </tr>
  <tr>
    <td>探索民族设计风格 网聚全球艺术精华</td>
  </tr>
</table>
</body>
</html>


注意下面,很有用!!!
a.classname:hover
a#IDname:hover
这两种写法,是分别配合.classname与#IDname使用的。它的作用范围变成了所有包含“class="classname"”或“ID="IDname"”的<a>置标符。这种写法,可以帮助你在同一页面中实现多种a:hover效果,可以看一下艺网(http://www.ArtHtml.com)的主页上导航栏文字与普通文章标题在鼠标时的区别。


四.应用:
1.置标符 自动应用
2.特制类 class="NAME"
3.ID   ID="IDname"
4.特殊对象 自动应用


五.CSS属性
CSS的属性有很多,像上文中用到最多的color,表示文字的颜色。background-color表示背景色。这个是最主要的,但是因为没有什么难度,参考一下相关手册就可以了。

CSS属性参考:http://www.arthtml.com/eNews/news/200502/0011_0000000271.html

CSS 标签属性/属性

行为属性 behavior

字体和文本属性 direction*

 direction
 font
 font-family
 font-size
 font-style
 font-variant
 font-weight
 ime-mode
 layout-grid
 layout-grid-char
 layout-grid-line
 layout-grid-mode
 layout-grid-type
 letter-spacing
 line-break
 line-height
 min-height ++
 ruby-align
 ruby-overhang
 ruby-position
 text-align
 text-autospace
 text-decoration
 text-indent
 text-justify
 text-kashida-space
 text-overflow ++ 
 text-transform
 text-underline-position
 unicode-bidi
 vertical-align
 white-space**
 word-break
 word-spacing ++(于 Macintosh 版本 4.0 中可用)
 word-wrap
 writing-mode

颜色和背景属性 background-attachment
 background-color
 background-image
 background-position
 background-position-x
 background-position-y
 background-repeat
 color

版面属性 border
 border-bottom
 border-bottom-color
 border-bottom-style
 border-bottom-width
 border-collapse*
 border-color
 border-left
 border-left-color
 border-left-style
 border-left-width
 border-right
 border-right-color
 border-right-style
 border-right-width
 border-style
 border-top
 border-top-color
 border-top-style
 border-top-width
 border-width
 clear
 float
 layout-flow
 margin
 margin-bottom
 margin-left
 margin-right
 margin-top
 padding
 padding-bottom
 padding-left
 padding-right
 padding-top
 scrollbar-3dlight-color
 scrollbar-arrow-color
 scrollbar-base-color
 scrollbar-darkshadow-color
 scrollbar-face-color
 scrollbar-highlight-color
 scrollbar-shadow-color
 table-layout*
 zoom

分类属性 display

 list-style
 list-style-image
 list-style-position
 list-style-type

定位属性 bottom*

 clip
 height
 left
 overflow
 overflow-x
 overflow-y
 position
 right*
 top
 visibility
 width
 z-index

打印属性 page**

 pageBreakAfter
 pageBreakBefore
 
滤镜属性 filter

伪类和其它属性 :active

 @charset
 cursor
 :first-letter**
 :first-line**
 @font-face
 :hover
 @import
 !important
 :link
 @media*
 @page**
 :visited



你可能感兴趣的:(html,css,Ruby)