HTML学习笔记——选择器
1> ID选择器、交叉选择器、群组选择器、子代选择器
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title> <style type="text/css">
p{
color: purple;
font-size: 25px;
} li{
font-size: 25px;
line-height: 35px;
} #two{
color: red;
} /* .lanse{
color: blue;
}*/ /*交叉选择器*/
li.lanse{
color:blue;
} /*群组选择器*/
#test,.seven{
color: orange;
} /*子代选择器*/
li span{
color: pink;
} </style> </head> <body>
<!-- 下面是html的写法 -->
<font color='blue' size='3'>下面是html的写法</font>
<font color='blue' size='3'>下面是html的写法</font>
<font color='blue' size='3'>下面是html的写法</font>
<font color='blue' size='3'>下面是html的写法</font>
<font color='blue' size='3'>下面是html的写法</font>
<font color='blue' size='3'>下面是html的写法</font> <!-- 下面是css的写法 -->
<p>下面是css的写法</p>
<p>下面是css的写法</p>
<p>下面是css的写法</p>
<p>下面是css的写法</p>
<p>下面是css的写法</p> <span>我是ul外面的span标签</span> <ul>
<li>我是第1行li标签
<span>我是ul里面的span标签</span></li>
<li id="two">我是第2行li标签</li>
<li class="lanse">我是第3行li标签</li>
<li>我是第4行li标签</li>
<li class="lanse">我是第5行li标签</li>
<li id="test">我是第6行li标签</li>
<li class="seven">我是第7行li标签</li>
</ul> <p class="lanse">我是class为lanse的p标签</p> </body>
</html>
2> 子选择器、相邻选择器、属性选择器、伪类选择器
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
/*子选择器*/
/*#box>p{
color:red;
}*/ /*相邻选择器*/
div+p{
color:blue;
} /*属性选择器*/
p[name]{
color:red;
} a{
font-size: 30px;
color:blue;
} /*伪类选择器*/
a:hover{
font-size: 50px;
color: red;
} #word{
width: 300px;
border: 3px solid blue;
margin: 0 auto;
} p#word:first-letter{
font-size: 50px;
color: red;
} div[name]{
color: yellow;
} </style>
</head> <body> <div name="box">我是name为box的div元素</div> <p id="word">p标签p标签p标签p标签p标签p标签</p> <a href="http://www.baidu.com">百度</a>
<br />
<br />
<br />
<div id="box">
<div id="son">
<p>我是son的p标签</p>
</div>
<p>我是box的p标签</p>
<p name="test">我是box的p标签</p>
<p>我是box的p标签</p>
</div>
</body>
</html>
3> 选择器的优先级
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#box{
font-size: 30px;
color: red;
} h1{
font-size: 40px;
color: orange;
}
/*有优先级*/
#title{
color: blue;
}
</style>
</head> <body>
<h1 id="title">今天是星期一</h1>
<div id="box">
<p>我是box里面的p标签</p>
<span>我是box里面的span标签</span>
</div> </body>
</html>
HTML学习笔记——选择器的更多相关文章
- JavaScript学习笔记-选择器集合调用方法
<script type="text/javascript"> function uu(namePd) { //判断id var reId = new RegExp(/ ...
- CSS学习笔记——选择器
选择器 当我们定义一条样式规则时候,这条样式规则会作用于网页当中的某些元素,而我们的规定的这些元素的规则就叫做选择器. 常用的选择器: 1.id选择器 #idname 2.类选择器 .classnam ...
- [CSS3] 学习笔记-选择器详解(三)
1.UI元素状态伪类选择器 在CSS3的选择器中,除了结构性伪类选择器外,还有一种UI元素伪类选择器.这些选择器的共同特征是:指定的样式只有当元素处于某种状态时才起作用,在默认状态下不起作用.在CSS ...
- [CSS3] 学习笔记-选择器详解(二)
1.选择器first-child.last-child.nth-child和nth-last-child 利用first-child.last-child.nth-child和nth-last-chi ...
- CSS学习笔记----选择器
用过css的同志们都知道,选择器是非常重要的,如果选择器使用不当,即使你的css写的再好,但是不知道要用在哪个元素上,这不是英雄无用武之地吗? css,用过的都说好! 最基本的选择器,id选择器,类选 ...
- css权威指南学习笔记 —— css选择器
1,选择器:选择器的一些基本常用规则基本都记得,w3c上都有,平时也常用,不常用的一些后代选择器经常就忘记了.一些归纳一下后代选择器,加深一下印象: a:子选择器: p>a a是直接是p的 ...
- jQuery学习笔记(一)jQuery选择器
目录 jQuery选择器的优点 基本选择器 层次选择器 过滤选择器 表单选择器 第一次写博客,希望自己能够长期坚持,以写博客的方式作为总结与复习. 最近一段时间开始学习jQuery,通过写一个jQue ...
- Object C学习笔记17-动态判断和选择器
当时学习Object C的时被人鄙视了一顿,说使用.NET的思想来学Object C就是狗屎:不过也挺感谢这位仁兄的,这让我学习的时候更加的谨慎.今天的学习笔记主要记录Object C中的动态类型相关 ...
- CSS学习笔记(1):选择器
一.元素选择器 HTML文档元素就是最基本的选择器 如: <!DOCTYPE html> <html lang="en"> <head> < ...
随机推荐
- canvas三角函数应用
这个是圆圈旋转的简单案例 var canvas=document.getElementById("canvas"); var cxt=canvas.getContext(" ...
- iOS不得姐项目--封装状态栏指示器(UIWindow实现)
一.头文件 #import <UIKit/UIKit.h> @interface ChaosStatusBarHUD : NSObject /** 显示成功信息 */ + (void)sh ...
- 【TYVJ 1463】智商问题 (闲得无聊)
老老实实写二分. #include<cstdio> #include<algorithm> using namespace std; int n, a[1000001], x; ...
- 51nod 1352 扩展欧几里德
给出N个固定集合{1,N},{2,N-1},{3,N-2},...,{N-1,2},{N,1}.求出有多少个集合满足:第一个元素是A的倍数且第二个元素是B的倍数. 提示: 对于第二组测试数据,集合分别 ...
- 【HDU 1542】Atlantis(线段树+离散化,矩形面积并)
求矩形面积并,离散化加线段树. 扫描线法: 用平行x轴的直线扫,每次ans+=(下一个高度-当前高度)*当前覆盖的宽度. #include<algorithm> #include<c ...
- SQLAlchemy 操作数据库
首先安装 SQLAlchemy install PyMySQL install sqlalchemy 代码: #!/usr/bin/env python # encoding: utf-8 " ...
- 在ORACLE触发器里调用JAVA程序
因为项目需要,有一个已经写好的Java程序,想要在Oracle某个表的触发器中调用,以使得每次数据更新时,调用这个JAVA程序,来修改后台某个数据. 现将过程记录如下: 1.编写JAVA程序 publ ...
- 【BZOJ-4353】Play with tree 树链剖分
4353: Play with tree Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 31 Solved: 19[Submit][Status][ ...
- codeforces 723C : Polycarp at the Radio
Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...
- VS2010 asp.net development server 无法展示svg图片
无解!只能使用IIS Express或者部署到服务器上的IIS能解决! 以下为解释: http://stackoverflow.com/questions/5981309/asp-net-develo ...