两种方法,分别如下:
⑴ 标记。
类名{标志属性:属性值;……标志属性:属性值}
引用方法是:<标记 CLASS=“类名”>
例如,我们打算让某一些段落缩进0.5in,另一些段落缩进 1.0in,我们知道段落采用< P>这个标记。
⑵ 可以直接定义CLASS,应用于HTML页面中的各个标记。
类名{标志属性:属性值;……标志属性:属性值}
引用方法是: <标记 CLASS="类名">
代码书写如下:
< html>
< head>
< title>This is a sample< /title>
< style type="text/css">
< !-- p.first { text-indent: 0.5in} p.second { text-indent: 1.0in} -->
< /style>
< /head>
< body bgcolor="#FFFFFF">
< p class="first">这个段落将缩进0.5in< /p> < p class="second">这个段落将比上面缩进一倍距离< /p>
< /body>
< /html>
<html>
<head>
<title>无标题文档</title>
<style type="text/css">
.head2 {text-align:center;font-size: 24px;font-style: italic;font-weight: bold;color: red;}
body{font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 15px;background-color: #FbFbFb; }
a:link {color: #0000FF ;text-decoration: none;}
a:visited {color: #00FF00;text-decoration: none;}
a:active {color: #FF0000;text-decoration: none;}
a:hover {text-decoration: underline;}
</style>
</head>
<body >
<span class="head2">This text is centered and red!</span>
<br>This text is centered and black!
<p style="color:#00FF00;font-style:normal;text-decoration:underline; ">This text is centered
and green!</p>
<a href="http://www.qdu.edu.cn" target="_blank">青岛大学</a><p>
<a href="http://www.qd.sd.cn" target="_blank">青岛信息港</a>
</body>
</html>
初步学习级联式样式表CSS、CSS的优点 (2009-5-9 0:23:0)
CSS中伪类的应用,伪类实现链接以不同形式展现 (2009-3-22 0:11:6)
如何在网页中插入CSS样式?介绍常用的几种方法。 (2009-3-21 23:36:44)
CSS的基本语法入门 (2009-3-21 22:29:14)
网页中CSS的使用方法有哪些?怎样用? (2009-3-20 18:31:54)
认识CSS,学习CSS前应该掌握哪些知识? (2009-3-20 18:17:25)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。