博主信息
博文 10
粉丝 0
评论 0
访问量 6785
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
3月21号作业
小议的博客
原创
772人浏览过

3月21号作业

基本选择器:

实例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>3-21基本选择器</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">

<style type="text/css">
	/*元素选择器*/
	ul {

		padding: 0;
		margin: 0 auto;
		width: 450px;	
		border: 1px dashed #666;
		padding: 10px 5px;
	}
	ul li{
		text-align: center;
		list-style: none;
	}
	/*class选择器*/
	.h2 {
		text-align: center;
	}
	.html {
		color: blue;
	}
	/*父子选择器*/
	ul li{
		background-color: #EFEFEF;

	}
	/*id选择器*/
	#css {
		color: red;
	}
	/*同配选择器*/
	ul * {
		font-size: 1.6em;
	}
	/*子选择器*/
	ul > li{
		color: purple;
	}
	/*相邻兄弟选择器,只选id后面一个用 “+” 全部用 “~”  */
	#mysql + li {
		color: black;
		font-size: xx-large;
		font-weight: bold;
	}
	#mysql ~ li {
		background-color: pink;
	}
</style>
</head>
<body>
	<h2 class="h2">必备技能</h2>
    <ul>
    	<li class="html">html</li>
    	<li id="css">css</li>
    	<li>javascript</li>
    	<li>php</li>
    	<li id="mysql">mysql</li>
    	<li>nginx</li>
    	<li>linux</li>
    	<li>不忘初心</li>
    	<li>加油,你最棒</li>
    </ul>
</body>
</html>

运行实例 »

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

属性选择器:

实例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>3-21属性选择器</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">

<style type="text/css">
	/*元素选择器*/
	ul {

		padding: 0;
		margin: 0 auto;
		width: 450px;	
		border: 1px dashed #666;
		padding: 10px 5px;
	}
	ul li{
		text-align: center;
		list-style: none;
	}
	/*class选择器*/
	.h2 {
		text-align: center;
	}

	/*选中所有有id属性的元素*/
	*[id] {
		color: red ;
		font-size: 1.2em;
		background-color: #666;
	}
	/*根据属性的名和值来选元素*/
	li[class="html"]{
		background-color: peachpuff ;
		font-size: 1.3em;
	} 
	/*选择class属性中包括指定单词的元素*/
	li[class ~="script"]{
		background-color: red;
		font-size: x-large;
	}
	/*选择以 ph 开头的类样式元素*/
	li[class ^="ph"] {
		background-color: #D6D7D8;
		font-family: cursive;
		font-style: oblique;
		font-size: 1.2em;
	}
	/*以x结尾的类样式元素*/
	li[class $="x"] {
		background-color: yellow;
		font-size: 1.3em;
	}
	li[class *="a"] {
		background-color:beige;
		color: brown;
	}

</style>
</head>
<body>
	<h2 class="h2">必备技能</h2>
    <ul>
    	<li class="html">html</li>
    	<li id="css">css</li>
    	<li class="script 2">javascript</li>
    	<li class="php 1">php</li>
    	<li class="php 2">php</li>
    	<li id="mysql">mysql</li>
    	<li class="nginx">nginx</li>
    	<li class="nginx">linux</li>
    	<li class="aahtml">不忘初心</li>
    	<li class="aacss" php css>加油,你最棒</li>
    </ul>
</body>
</html>

运行实例 »

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

手抄代码:

1.jpg

2.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+教程免费学