1.postion之staic

:nth-child(n) ---->选中某个元素,该元素必须是某个父元素下的第n个子元素
2.postion之relative

相对于自己原来位置坐偏移
z-index:可用于将在一个元素放置于另一元素之后

3.postion之absolute

相对最近的relative布局
.parent {
position: relative;
width: 200px;
height: 150px;
background: blue;
}
.child {
position: absolute;
width: 80px;
height: 80px;
background: red;
right: -80px;
top:0;
}
垂直居中:
.child {
position: absolute;
width: 80px;
height: 80px;
background: red;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto auto;
}
4.positon之fixed

5.poistion之sticky(CSS3)


网友评论