CSS选择器

1.标签选择器

<style  type="text/css">

p    //格式对p标签起作用

{

    样式;

}

</style>

2.class选择器--都是“.”开头

<head>

<style type="text/css">

.main    /*定义样式*/

{

    height:34px;

    width:67px;

    text-align:center;

}

</style>

</head>

<body>

<div class="main">

</div>

</body>

3.ID选择器--以“#”开头

<div  id="样式名">

<head>

<style type="text/css">

#main    /*定义样式*/

{

    height:34px;

    width:67px;

    text-align:center;

}

</style>

</head>

<body>

<div id="main">

</div>

</body>

4.复合选择器

(1)用“,”隔开,表示并列

<style  type="text/css">

p,span  /*标签p,span两者同样的样式*/

{

  样式;

}

</style>

(2)用空格隔开,表示后代

<style  type="text/css">

.main  p  /找到使用“main”的标签,在该标签里的p标签使用该样式/

{

  样式;

}

</style>

(3)筛选“.”

<style  type="text/css">

p.sp  /在标签p中的clss="sp"的标签,执行以下样式/

{

  样式;

}

</style>

 

posted @ 2017-01-03 17:06  周全264  阅读(104)  评论(0编辑  收藏  举报