<!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...
}
例子:
.two{
background-color:#0F0;
color:#F00;
font-size:24px;
}
类选择器要注意的事项:
1. html元素的class属性值一定不能以数字开头.
2. 类选择器的样式是要优先于标签选择器的样式。
3. ID选择器: 使用ID选择器首先要给html元素添加一个id的属性值。
ID选择器的格式:
#id属性值{
样式1;样式2...
}
id选择器要注意的事项:
1. ID选择器的样式优先级是最高的,优先于类选择器与标签选择器。
2. ID的属性值也是不能以数字开头的。
3. ID的属性值在一个html页面中只能出现一次。
4. 交集选择器: 就是对选择器1中的选择器2里面的数据进行样式化。
选择器1 选择器2{
样式1,样式2....
}
例子:
.two span{
background-color:#999;
font-size:24px;
}
5. 并集选择器: 对指定的选择器进行统一的样式化。
格式:
选择器1,选择器2..{
样式1;样式2...
}
span,a{
border-style:solid;
border-color:#F00;
}
6. 通过选择器:
{
样式1;样式2...
}
*/
*{
text-decoration:line-through;
background-color:#CCC;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<div id="one" class="two">这个是<span>第一个div标签</span>...</div>
<div id="one" class="two">这个是<span>第二个div标签</span>...</div>
<span>这个是一个span标签</span><br/>
<a class="two" href="#">新闻标题</a>
</body>
</html>
Css详解之(选择器)
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【CSS】第九讲:CSS基本选择器(1)
本文讲了部分CSS选择器
选择器 属性值 基本语法 -
css选择器详解
标签选择器渲染所有的指定的标签。* 以下例子渲染所以的span<!DOCTYPE ht
选择器 css html 定义类 -
Css详解之(伪类选择器)
无标题文档 百度 伪类选择器案例: 无标题文档 姓名 成绩 人品 ...
html 伪类选择器 xml css 3c