CSS的class选择器
一 介绍
class选择器用于描述一组元素的样式,class选择器有别于id选择器,class可以在多个元素中使用。
class选择器在HTML中以class属性表示,在CSS中,类选择器以一个点”.”号显示:
在下面的的例子中,所有拥有center类的HTML元素均为居中。
二 代码
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>菜鸟学习</title>
<style>
.center
{
text-align:center;
}
</style>
</head>
<body>
<h1 class="center">标题居中</h1>
<p class="center">段落居中。</p>
</body>
</html>
三 运行效果
还没有评论,来说两句吧...