批改状态:未批改
老师批语:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>css之选择器</title>
<!-- css样式引用1 -->
<link rel="stylesheet" type="text/css" href="">
<!-- css样式2 -->
<style type="text/css">
/*---css之元素选择器---*/
/*一般用于初始化的选择器*/
*{
color: red;
}
/*类选择器*/
.one{
color: blue;
}
/*ID选择器*/
#two{
color: green;
}
/*相邻兄弟选择器*/
#two + p{
color: white;
}
/*相邻全部兄弟选择器*/
#two + p ~p{
color:black;
}
/*---css之属性选择器---*/
/*也是一个父子类型的选择*/
#div2 ul li{
height: 20px;
width: 50px;
background-color: blue;
margin: 3px;
}
/*属性选择*/
#div2 *[id] {
width: 100px;
}
/*名值对*/
#div2 [class="male"] {
width: 120px;
}
/*指定单词*/
#div2 [class="female"] {
width: 120px;
}
/*以某几个之母开头或结尾的*/
/*[class $="e"] 这个结尾*/
#div2 [class ^="m"] {
width: 150px;
}
/*值包括指定字母*/
#div2 [class *="a"] {
width: 200px;
}
/*伪类选择*/
/*第一个和最后一个*/
h1:first-child {
background-color: black;
}
div p:last-child {
background:#ff0000;
}
/*唯一的区别*/
p:only-child{
color:white;
}
h1:only-of-type{
font-size: 8px;
}
#div2 ul li:nth-child(3){
height: 50px;
}
</style>
</head>
<body bgcolor="#ccc">
<!-- css样式3 -->
<h1 style="color: blue">css之选择器</h1>
<!-- 元素选择器演示 -->
<div>
<h1 class="one">css之元素选择器</h1>
<p class="one">我是元素1</p>
<p id="two">我是元素2</p>
<p>我是元素3</p>
<p>我是元素4</p>
</div>
<!-- css之属性选择器 -->
<div id="div2">
<h1>葫芦娃之七兄弟战力排行之css属性选择器</h1>
<ul>
<li id="dag" >大娃</li>
<li class="green">二娃</li>
<li class="male">三娃</li>
<li id="dag" class="male">四娃</li>
<li>五娃</li>
<li id="dag" class="female abc">六娃</li>
<li class="mmee">七娃</li>
</ul>
</div>
<div>
<p>唯一的</p>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例

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