博主信息
博文 26
粉丝 0
评论 0
访问量 23955
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
3.21标签选择器
十一
原创
944人浏览过

基本选择器:

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>基本选择器</title>
	<style type="text/css">
	h1{
		size: 44px;
		color:red;
	}
	#t1{
		size: 22px;
		color: yellow;background-color: green
	}
	.green{
		size: 58;background-color: yellow
	}
	ol li{
		size: 35;color:DarkMagenta;
		 }
	tr * {
		background-color: red
	}
	ul > li{
		color:#8B0000;
	}
	</style>
</head>
<body>
	<h1 style="color: blue">元素选择器</h1>
	<ul type="none">
		<li id="t1">ID选择器/#加ID值</li>
		<li class="green">类选择器1/.+class值</li>
		<li class="red">3</li>
		<li class="green">类选择器2</li>
		<li>5</li>
		<li id="t2">6</li>
		<li>7</li>
		<li>8</li>
		<li>9</li>
		<li>10</li>
	</ul>
	<ol>
		<li>父子选择器</li>
		<li>父子选择器</li>
		<li>父子选择器</li>
		<li>父子选择器</li>
	</ol>
<table border="1">
	<tr>
		<th>通配选择器</th>
		<th>通配选择器</th>
		<th>通配选择器</th>
	</tr>
</table>
<dl>
	<dt>子元素选择器</dt>
	<dd>子元素选择器</dd>
</dl>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>基本选择器2</title>
	<style type="text/css">
	ol > li{
		font-size: 67px;color: red;
	}
	#t2 + li{
		background-color: blue;color: red
	}
	#t3 ~ li{
		color: skyblue
	}

	</style>
</head>
<body>
		<h1 style="color: blue">元素选择器</h1>
	<ul type="none">
		<li id="t1">ID选择器/#加ID值</li>
		<li class="green">类选择器1/.+class值</li>
		<li class="red">3</li>
		<li class="green">类选择器2</li>
		<li>5</li>
		<li id="t2">6</li>
		<li>相邻兄弟选择器</li>
		<li id="t3">8</li>
		<li>全部兄弟选择器</li>
		<li>全部兄弟选择器</li>
		<li>全部兄弟选择器</li>

	</ul>
	<ol>
		<li>子元素选择器</li>
		<li>子元素选择器</li>
		<li>子元素选择器</li>
		<li>子元素选择器</li>
	</ol>
<table border="1">
	<tr>
		<th>通配选择器</th>
		<th>通配选择器</th>
		<th>通配选择器</th>
	</tr>
</table>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

属性选择器

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>属性选择器</title>
	<style type="text/css">
		* [id] {
		size: 44px;color: red;
		}
		li[class="green"]{
			size:55px;background: red;

		}
		li[class~="red"]{
			color: blue
		}
		li[class ^= "ph"] {
			background-color: coral;
		}
		li[class $= "s"]{
			color:skyblue
		}
		li[class *= "a"]{
			background-color: lime;
		}
			</style>

</head>
<body>
		<ul type="none">
		<li id="item1">根据属性名来选择“id属性”</li>
		<li class="green">根据属性名与值来选择</li>
		<li class="green red">选择class属性值中包括指定单词的元素RED</li>
		<li class="red">选择class属性值中包括指定单词的元素red</li>
		<li class="abc">选择属性值中包括指定字母'a'的类样式元素</li>
		<li id="item2">根据属性名来选择“id属性”</li>
		<li class="php">选择以'ph'字母开头的class类样式元素</li>
		<li class="php css">选择以'ph'字母开头的class类样式元素+选择以's'结尾的类样式元素</li>
		<li>9</li>
		<li>10</li>
	</ul>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

手抄基础选择器

QQ图片20180322192556.jpg

QQ图片20180322192608.jpg

批改状态:未批改

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学