css定义选择器

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	</head>
	<style type = "text/css">
		
		#title
		{
			color:red;
		}
		   
	</style>
	<body>
		<!-- 应用id选择器 -->
		<p id = "title">PHP100.COM中文网</p>
	</body>
</html>  

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	</head>
	<style type = "text/css">
		
		/*只适合title的h2标题*/
		p#title
		{
			color:blue;
		}
		
		h2#title
		{
			color:red;
		}
		   
	</style>
	<body>
		<!-- ID与选择器结合 -->
		<h2>PHP100.COM中文网</h2>
		<h2 id = "title">Crazy工程师</h2>
		<p id = "title">胡心鹏同学--home.bigbird</p>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	</head>
	<style type = "text/css">
		.php
		{
			color:red;
		}
		
		   
	</style>
	<body>
		<!-- 应用类 -->
		<p class= "php">PHP100.COM中文网</p>
		<p class= "php">PHP100.COM中文网</p>
		<p class= "php">PHP100.COM中文网</p>
		<p class= "php">PHP100.COM中文网</p>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	</head>
	<style type = "text/css">
		ul#drinks
		{
			line-height:200%;
			color:red;
			
		}
		li.mix
		{
			font-size:20px;
		}
		li.hot
		{
			font-size:30px;
		}
		   
	</style>
	<body>
		<!-- 结合多个类和ID -->
		<ul id = "drinks">
			<li class = "mix">啤酒</li>
			<li class = "mix">可乐</li>
			<li class = "hot">红茶</li>
			<li class = "hot">绿茶</li>
		</ul>
		
		<p id = "drinks">PHP100.COM</p>
		<p class = "hot">胡心鹏 -- 魔兽争霸全国冠军(梦里面)</p>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	</head>
	<style type = "text/css">
		p
		{
			color:red;
			font-size:30px;
		}
		p.title
		{
			color:blue;
			font-size:40px;
		}
	</style>
	<body>
		<!-- 利用类改写样式 -->
		<p class = "title">PHP100.COM中文网</p>
		<strong class = "title">PHP100.COM中文网</strong>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	</head>
	<style type = "text/css">
		p.title
		{
			color:red;
			font-size:30px;
		}
		
	</style>
	<body>
		<!-- 直接将类链接到元素上 -->
		<p class = "title">PHP100.COM中文网</p>
		<strong class = "title">PHP100.COM中文网</strong>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		
		<link rel = "stylesheet" type = "text/css" href = "3.css"/>
		<link rel = "stylesheet" type = "text/css" href = "1.css"/>
		<link rel = "stylesheet" type = "text/css" href = "2.css"/>
	</head>
	
	<body>
		<!-- 叠层 -->
		<!-- 如果有冲突,并且优先级是一样高的,谁在最下层谁的优先级最高 -->
		<!-- 必须牢记一个规则,越晚给的规则越重要 -->
		<p class = "title">PHP100.COM中文网</p>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			h1,h2,h3
			{
				color:red;
				font-size:20px;
			}
			h1
			{
				font-family:Arial Black;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 分组 -->	
		<h1>PHP100.COM中文网</h1>
		<h2>PHP100.COM中文网</h2>
		<h3>PHP100.COM中文网</h3>
	</body>


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			body
			{
				color:red;
				font-size:20px;
				font-weight:normal;
			}
			h1
			{
				font-weight:normal;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 继承 -->	
		<h1>PHP100.COM的中文网</h1>
		<i>很靠谱</i>
		<p>李炎恢老师</p>
		<span>胡心鹏同学</span>
		<div>杨金环同学</div>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>定义选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			h1#php
			{
				color:red;
			}
			
			/*h1下面的i的样式是 */
			h1#php i
			{
				color:green;
				font-style:normal;
				text-decoration:underline;
			}
			
			
			h1#sina
			{
				color:blue;
			}
			
			/*h1下面的i的样式是 */
			h1#sina i
			{
				color:pink;
				font-style:normal;
				text-decoration:underline;
			}
			
			
		</style>
		
	</head>
	
	<body>
		<!-- 上下文选择器 -->
		<!-- 尽量在标签里面的标签不设定class、id -->
		<h1 id = "php">PHP100.COM<i>很靠谱</i>的中文网</h1>
		<h1 id = "sina">http://www.sina.com.cn<i>新浪网</i>,门户网</h1>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>子类选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			div.box
			{
				color:red;
			}
			div.box1
			{
				font-weight:bold;
			}
			div.box2 
			{
				font-style:italic;
			}
			div.box3
			{
				font-size:30px;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 子类选择器 -->
		<!-- 让第二个div变粗体 -->
		<div class = "box">PHP100.COM中文网</div>
		<div class = "box box1 box3">PHP100.COM中文网</div>
		<div class = "box box2">PHP100.COM中文网</div>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>其他选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			<!-- IE6、IE7没效果 -->
			input:focus
			{
				background:orange;
				border:1px solid green;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 其他选择器 --> 
		<!-- 伪类选择器 -->
		<input type = "text" />
		
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>通用选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			/*繁琐方式*/
			/*h1,h2,h3,h4,h5,p,ul,div,body,html
			{
				margin:0;
				padding:0;
			}*/
			
			*
			{
				margin:0;
				padding:0;
			}
			
		</style>
		
	</head>
	
	<body>
		<h4>PHP100.COM中文网</h4>
		<h4>PHP100.COM中文网</h4>
		<h4>PHP100.COM中文网</h4>
		<h4>PHP100.COM中文网</h4>
		
		<p>PHP100.COM中文网</p>
		<p>PHP100.COM中文网</p>
		<p>PHP100.COM中文网</p>
		
		<ul>
			<li>PHP100.COM中文网</li>
			<li>PHP100.COM中文网</li>
			<li>PHP100.COM中文网</li>
		</ul>
	</body>
</html> 


 

<!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">
<html>
	<head>
		<title>高级选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			ul#nav
			{
				list-style-type:none;
				line-height:150%;
			}
			
			ul#nav ul
			{
				list-style-type:none;
			}
			
			/*如果用大于号 ul#nav下的li下的li 将不应用该样式*/
			/*只能选儿子不能选孙子*/
			ul#nav > li 
			{
				background:url("tb.gif") no-repeat left center;
				padding-left:15px;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 高级选择器 -->
		<!-- IE6不支持,IE7、火狐支持 -->
		
		<ul id = "nav">
			<li>PHP100.COM中文网</li>
			<li>
				<ul>
					<li>PHP100.COM中文网</li>
					<li>PHP100.COM中文网</li>
				</ul>
			</li>
			<li>PHP100.COM中文网</li>
		</ul>
	</body>
</html> 


 

<!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">
<html>
	<head>
		<title>相邻同胞选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			h1+p
			{
				font-weight:bold;
				color:red;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 相邻同胞选择器 -->
		<!-- 尽量不要在标签里加class id-->
		<!-- IE6以下不支持 -->
		<h1>PHP100.COM</h1>
		<p>中文网</p>
		<p>很靠谱</p>
	</body>
</html>  


 

<!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">
<html>
	<head>
		<title>属性选择器</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<style type = "text/css">
			/*----------------------------------
			下面支持IE7.0以上,firefox2.0以上
			下面支持IE7.0以上,firefox2.0以上
			下面支持IE7.0以上,firefox2.0以上
			下面支持IE7.0以上,firefox2.0以上
			下面支持IE7.0以上,firefox2.0以上
			------------------------------------*/
			
			/*
				自我提示
			*/
			
			strong[title]
			{
				color:red;
				background:orange;
				display:block;
			}
			
			strong[title]:hover
			{
				border:1px dashed #333;
				background:green;
				cursor:pointer;
				display:block;
			}
			
		</style>
		
	</head>
	
	<body>
		<!-- 属性选择器 -->
		<!-- IE6.0不支持 -->
		<!-- IE6.0 只支持超链接的伪类 -->
		<!-- IE7.0+ 所有标签基本都支持 -->
		<strong title = "很靠谱的PHP中文社区">PHP100.COM中文网</strong>
		
		<strong>李炎恢老师</strong>
	</body>
</html>  



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值