css-------选择器

来源:互联网 发布:mac单机游戏推荐 编辑:程序博客网 时间:2024/06/06 19:46
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
/*
选择器: 作用:找到对应的数据进行样式化
1.标签选择器: 找到所有指定的标签进行样式化
格式:
标签名{
样式1;样式2;...
}


div{
color:#F00;
font-size:24px;
}
2.类选择器: 使用类选择器首先要给html标签指定对应的class属性值。
格式:
.class的属性值{
样式1;样式2;...
}
注意:(1)html元素的class属性值,不能以数字开头。
(2)类选择器的样式优先于标签选择器的样式。
3.id选择器: 使用id选择器,首先要给html元素添加一个id的属性值。
格式:
#id的属性值{
样式1;样式2...
}
注意:(1)id选择器优先级最高的,优先于类选择器和标签选择器。
4.交集选择器 对选择器1中的选择器2里面的数据进行样式化
格式: 选择器1 选择器2{
样式1;样式2;...
}
5.并集选择器 对指定的选择器进行统一的样式化
格式: 选择器1,选择器2...{
样式1;样式2;...
}
6.通用选择器
格式: *{
样式1;样式2...
}

.two_12{
background-color:#CF3;
color:#0F0;
font-size:24px;
}

div{
background-color:#6F9;
}
.test{
background-color:#0F0;
}
#one{
background-color:#FF9;
color:#33C;
font-weight:18px;
}
div span{
background-color:#999;
font-size:24px;
}


span,a{
border-style:solid;
border-color:#0FF;
}
*/
*{
text-decoration:line-through;
background-color:#CCC;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>2选择器</title>
</head>
<body>
<div id="one" class="test">这个是<span>第一个div标签</span>...</div>
    <div class="two_12">这个是<span>第一个div标签</span>...</div>
    <span>这是一个span段落标签</span></br>
    <a href="#" class="two_12">新闻标题</a>




</body>
</html>
0 0
原创粉丝点击