p1.after和hover的使用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#ii{
width:100px;
height: 100px;
border-radius:100%;
border:5px solid navajowhite;
margin-left:200px;
text-align:center;
}
#ii::after{ /* 创建伪元素content中添加内容 */
content:"猴王";
font-family: '宋体';
position:relative;
top:40px;
}
#ii:hover{ /* 鼠标移入改变背景颜色 */
background-color: pink;
}
</style>
</head>
<body>
<div id="ii"></div>
</body>
</html>
2.z-index的使用 (数值大的在上)
3.文档流样式inline
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
li{
display:inline;
}</style>
</head>
<body>
<ul>
<li>大家好 我是猴王!</li>
<li>大家好 我是猴王!</li>
<li>大家好 我是猴王!</li>
<li>大家好 我是猴王!</li>
<li>大家好 我是猴王!</li>
</ul>
</body>
</html>
4.合并单元格
th标签表头单元格
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
table{
width:400px;
height:400px;
}
td{
border:1px solid black;
}
#cont{
transform:translateX(500px);
}
#cont1{
transform:translateY(-400px);
}</style>
</head>
<body>
<table id="cont">
<tr>
<td colspan='2'></td><!-- 合并行 -->
<td></td>
<!-- <td></td> -->
</tr>
<tr>
<td></td>
<td></td>
<td rowspan='2'></td><!-- 合并列 -->
</tr>
<tr>
<td></td>
<td></td>
<!-- <td></td> -->
</tr>
</table>
<table id="cont1">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
5.input表单元素
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<input type="text" placeholder="默认显示" maxlength="6"> <!-- 最大输入6位数 -->
<br>
<input type="password" placeholder="输入显示*">
<br>
<input type="button" value="我是一个按钮">
<br>
<input type="checkbox"><!-- 一个勾选框 -->
<br>
<input type="radio"><!--选中后不可以取消-->
<br>
<input type="checkbox" checked="checked"><!-- 一个勾选框 默认选中-->
<br>
<input type="radio" id = "nan" name="nex"><label for="nan">男</label>
<input type="radio" id = "nv" name="nex"><label for="nv">女 只能选择一个</label>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#w input{
border:0;/*清除自带边框*/
outline:none;/*清除点击后的边框*/
}
*{
box-sizing: border-box;/*设置内边距不会把盒子挤大*/
}
#q input{
width:100px;
padding-left:20px;
}
</style>
</head>
<body>
<div id="w">
<!--search类型带清除小叉叉-->
<input type="search" placeholder="默认显示">
</div>
<div id="q">
<input type="text" placeholder="默认显示">
</div>
</body>
</html>
6.消除边框
border-collapse: collapse;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
table{
height:400px;
width:400px;
margin: 0;
padding: 0;
border-collapse: collapse;
}
td{
border:1px solid blue;
}
</style>
</head>
<body>
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
6.找儿子和孙子
7.下拉菜单
8.清除浮动
9.京东秒杀
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#kuang{
position: absolute;
right: 0;
top: 0;
width: 0;
height: 0;
border-color:transparent white transparent transparent;
border-style:solid;
border-width: 30px 15px 0 0;
}
#kuan{
width: 0;
height: 0;
border-color:transparent blue transparent transparent;
border-style:solid;
border-width: 24px 10px 0 0;
}
#q{
border:1px solid pink;
width: 160px;
height: 30px;
line-height: 30px;
margin: 0 auto;
}
#p{
position: relative;
float:left;
width: 80px;
background: red;
text-align: center;
color:white;
}
#o{
width: 80px;
float:right;
text-align: center;
text-decoration: line-through;
}
</style>
</head>
<body>
<div id ="kuan"></div>
<div id="q">
<span id="p">$5999<i id="kuang"></i></span>
<span id="o">$5999</span>
</div>
</body>
</html>
10.overflow元素
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div>#aa{
float: left;
border:2px solid red;
width: 130px;
height: 180px;
margin:10px;
}
.q1{
overflow: hidden;/*溢出部分隐藏*/
}
.q2{
overflow: scroll;/*总是显示滚动条*/
}
.q3{
overflow: auto;/*超出显示滚动条 不超出不显示*/
}
.q4{
overflow: visible;/*不剪切内容也不添加滚动条*/
}</style>
</head>
<body>
<div>
<div id="aa" class="q1">
<a>京东JD.COM-专业的综合网上购物商城,为您提供正品低价的购物选择
、优质便捷的服务体验。商品来自全球数十万品牌商家,囊括家电、
手机、电脑、服装、居家、母婴、美妆、个护、食品、生鲜等丰富品类,满足各种购物需求。</a></div>
<div id="aa" class="q2">
<a>京东JD.COM-专业的综合网上购物商城,为您提供正品低价的购物选择
、优质便捷的服务体验。商品来自全球数十万品牌商家,囊括家电、
手机、电脑、服装、居家、母婴、美妆、个护、食品、生鲜等丰富品类,满足各种购物需求。</a>
</div>
<div id="aa" class="q3">
<a>京东JD.COM-专业的综合网上购物商城,为您提供正品低价的购物选择
、优质便捷的服务体验。商品来自全球数十万品牌商家,囊括家电、
手机、电脑、服装、居家、母婴、美妆、个护、食品、生鲜等丰富品类,满足各种购物需求。</a></div>
<div id="aa" class="q4">
<a>京东JD.COM-专业的综合网上购物商城,为您提供正品低价的购物选择
、优质便捷的服务体验。商品来自全球数十万品牌商家,囊括家电、
手机、电脑、服装、居家、母婴、美妆、个护、食品、生鲜等丰富品类,满足各种购物需求。</a>
</div>
</div>
</body>
</html>
11.鼠标样式
12.设置中心点
>> 旋转案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div{
overflow: hidden;/*隐藏before伪元素*/
position: relative;
width: 100px;
height: 100px;
border:1px solid pink;
margin: 100px 100px;
}
div::before{
content: "猴王";
line-height: 100px;
text-align: center;
/*before是行类块元素要转换为块级元素*/
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: pink;
transform-origin: left bottom;/*选择中心点*/
transform: rotate(180deg);/*选择旋转角度*/
transition: all .6s;/*添加过渡动画时长*/
}
div:hover::before{
transform: rotate(0deg);
}
</style>
</head>
<body>
<div></div>
<div></div>
</body>
</html>
13.steps使用(指定了时间函数中间隔数量)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div{
overflow: hidden;
height: 50px;
font-size: 40px;
width: 0;
background: pink;
white-space: nowrap;/*文字强制一行显示*/
animation: w 6s steps(6) forwards;
}
@keyframes w{
0%{
width: 0;
}
100%{
width: 240px;
}
}</style>
</head>
<body>
<div id="s">重庆高等猴王</div>
</body>
</html>
14.旋转案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body{
perspective: 500px;
}
#box{
position: relative;
width: 100px;
height: 100px;
margin:100px auto;
transition: all 2.0s;
transform-style: preserve-3d;
}
#box:hover{
transform: rotateY(60deg);
}
#box div{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: pink;
}
#box div:last-child{/*设置box中最后一个div标签*/
background: purple;
transform: rotateX(60deg);
}
</style>
</head>
<body>
<div id="box">
<div></div>
<div></div>
</div>
</body>
</html>
15.文字阴影
16.clac函数
17.nth-child选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#hh,#kk{
float: left;
margin-left:20px;
width: 120px;
height: 620px;
border:2px solid red;
}
#qq,#pp{
width: 100px;
height: 20px;
margin-top:10px;
margin-left:10px;
}
#qq:nth-child(even){/*选择偶数*/
background: pink;
}
#qq:nth-child(odd){/*选择奇数*/
background: palegreen;
}
#pp:nth-child(n){
background:chocolate;
}
#pp:nth-child(3n-1){
background: yellow;
}
#pp:nth-child(3n-2){
background:paleturquoise;
}
</style>
</head>
<body>
<div id="hh">
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
<div id="qq"></div>
</div>
<div id = "kk">
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
<div id="pp"></div>
</div>
</body>
</html>
18.flex弹性布局