raedon

       My free space. To make my world be in order.  

导航

 

class 选择器

1、class 选择器用于描述一组元素的样式,class 选择器有别于id选择器,class可以在多个元素中使用。

2、class 选择器在HTML元素中以class属性(即class=??)表示,

3、在 CSS 中,类选择器以一个点"."号显示,(即以一个“.”定义一个特定属性)

4、在以下的例子中,所有拥有 center 类的 HTML 元素均为居中。(所有的HTML元素若被class=??赋值均被设置了特定属性)

 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>我的css</title>
<style>
.center
{
 text-align:center;
}
</style>
</head>

<body>
<h1 class="center">标题居中</h1>
<p class="center">段落居中。</p>
</body>
</html>

posted on 2018-01-13 19:11  raedon  阅读(752)  评论(0)    收藏  举报