使用 CSS(样式表)的 class
来源:互联网 发布:如何安装proteus软件 编辑:程序博客网 时间:2024/05/17 15:58
class 是类,用来定义 style 属性。
在使用 CSS(样式表)时用 class 可以更方便。
举例:
文件1:C1.CSS
.Bar
{
border-right: 2px outset;
border-top: 2px outset;
overflow: auto;
border-left: 2px outset;
border-bottom: 2px outset;
}
.BCap
{
color: graytext;
}
.BDroper
{
border-right: 2px outset;
border-top: 2px outset;
border-left: 2px outset;
width: 1px;
cursor: move;
border-bottom: 2px outset;
position: static;
height: 100%;
}
这个文件定义了三个类(class):
Bar 工具栏的样式
BCap 工具栏标题的样式
BDroper 工具栏拖动按钮的样式
文件2:Main.HTM (HTML)
<HTML>
<HEAD>
<LINK href="C1.CSS" type=text/css rel=stylesheet> <!--样式表的路径-->
</HEAD>
<BODY>
<DIV class="Bar">
<a class="BDroper"></a>
<a class="BDroper"></a>
<a class="BCap">浏览</a>
<a href="javascript:history.back(1)">返回</a>
<a href="javascript:history.forward(1)">前进</a>
</DIV>
<BODY>
</HTML>
如果不是用样式表,文件2的内容如下:
<HTML>
<HEAD>
<!--没有样式表-->
</HEAD>
<BODY>
<DIV style="border-right: 2px outset; border-top: 2px outset; overflow: auto; border-left: 2px outset; border-bottom: 2px outset;">
<a style="border-right: 2px outset; border-top: 2px outset; border-left: 2px outset; width: 1px; cursor: move; border-bottom: 2px outset; position: static; height: 100%;"></a>
<a style="border-right: 2px outset; border-top: 2px outset; border-left: 2px outset; width: 1px; cursor: move; border-bottom: 2px outset; position: static; height: 100%;"></a>
<a style="color: graytext;">浏览</a>
<a href="javascript:history.back(1)">返回</a>
<a href="javascript:history.forward(1)">前进</a>
</DIV>
<BODY>
</HTML>
可见,如果使用样式表以及 class 属性,则对于样式的定义就能简单的多。
<a href="index.jsp" class="atop">
这定义了一个超链接,它的类为 atop。如果你能找到这个网页的样式表,你会找到这个类的定义。也许是这样的:
.atop
{
.....
}
当然,一个网页也可以使用多个样式表:
...
<HEAD>
<LINK href="C1.CSS" type=text/css rel=stylesheet> <!--样式表1的路径-->
<LINK href="../C2.CSS" type=text/css rel=stylesheet> <!--样式表2的路径-->
<LINK href="DD1/S1/Main.CSS" type=text/css rel=stylesheet> <!--样式表3的路径-->
</HEAD>
...
在使用 CSS(样式表)时用 class 可以更方便。
举例:
文件1:C1.CSS
.Bar
{
border-right: 2px outset;
border-top: 2px outset;
overflow: auto;
border-left: 2px outset;
border-bottom: 2px outset;
}
.BCap
{
color: graytext;
}
.BDroper
{
border-right: 2px outset;
border-top: 2px outset;
border-left: 2px outset;
width: 1px;
cursor: move;
border-bottom: 2px outset;
position: static;
height: 100%;
}
这个文件定义了三个类(class):
Bar 工具栏的样式
BCap 工具栏标题的样式
BDroper 工具栏拖动按钮的样式
文件2:Main.HTM (HTML)
<HTML>
<HEAD>
<LINK href="C1.CSS" type=text/css rel=stylesheet> <!--样式表的路径-->
</HEAD>
<BODY>
<DIV class="Bar">
<a class="BDroper"></a>
<a class="BDroper"></a>
<a class="BCap">浏览</a>
<a href="javascript:history.back(1)">返回</a>
<a href="javascript:history.forward(1)">前进</a>
</DIV>
<BODY>
</HTML>
如果不是用样式表,文件2的内容如下:
<HTML>
<HEAD>
<!--没有样式表-->
</HEAD>
<BODY>
<DIV style="border-right: 2px outset; border-top: 2px outset; overflow: auto; border-left: 2px outset; border-bottom: 2px outset;">
<a style="border-right: 2px outset; border-top: 2px outset; border-left: 2px outset; width: 1px; cursor: move; border-bottom: 2px outset; position: static; height: 100%;"></a>
<a style="border-right: 2px outset; border-top: 2px outset; border-left: 2px outset; width: 1px; cursor: move; border-bottom: 2px outset; position: static; height: 100%;"></a>
<a style="color: graytext;">浏览</a>
<a href="javascript:history.back(1)">返回</a>
<a href="javascript:history.forward(1)">前进</a>
</DIV>
<BODY>
</HTML>
可见,如果使用样式表以及 class 属性,则对于样式的定义就能简单的多。
<a href="index.jsp" class="atop">
这定义了一个超链接,它的类为 atop。如果你能找到这个网页的样式表,你会找到这个类的定义。也许是这样的:
.atop
{
.....
}
当然,一个网页也可以使用多个样式表:
...
<HEAD>
<LINK href="C1.CSS" type=text/css rel=stylesheet> <!--样式表1的路径-->
<LINK href="../C2.CSS" type=text/css rel=stylesheet> <!--样式表2的路径-->
<LINK href="DD1/S1/Main.CSS" type=text/css rel=stylesheet> <!--样式表3的路径-->
</HEAD>
...
- 使用 CSS(样式表)的 class
- 样式表CSS的使用
- CSS自学笔记(3):CSS样式表的使用
- CSS 同时具备两个class的样式
- 使用CSS样式表
- 编写和使用的CSS样式表
- CSS样式表高效使用的技巧
- CSS样式表高效使用的技巧
- CSS样式表的分类及使用
- css样式的使用(一)
- hta工具:从.css文件中清理不使用的样式类(id或class类)
- css样式的使用一
- CSS:class选择器的使用
- 关于css样式表的的使用和插入css样式表的几种方法
- 引用css样式时,一个class引用两个样式的写法( class="ico001 icoCom")。
- 漂亮的表格样式(使用CSS样式表控制表格样式)
- 漂亮的表格样式(使用CSS样式表控制表格样式)
- 漂亮的表格样式(使用CSS样式表控制表格样式)
- CCIE试验备考之交换TRUNK(待看)
- 巧用 CCProxy 阻止非法下载
- 对静态变量和全局变量的认识
- 做投机别太多主观
- 对象的序列化和反序列化实践
- 使用 CSS(样式表)的 class
- 移动(增加删除)option 增加难度疑问
- c++编译中无法解析外部符号的解决方法
- 股民必须牢记的“二十一条军规”
- Linux在教育产业的机会
- 今天的smarty心得
- 欢迎来到Lotus博客圈官方博客
- 编程心得
- 余世维:为什么抓得住机会的人很少?