今天學(xué)到的
相對定位篮条,絕對定位
position:relative;absolute;
//相對定位就是元素對于整個網(wǎng)頁位置是正常的;
//絕對定位就是子元素相對于父元素的位置(離他最近的父元素);
//傳參有:top:;bottom:;left:;right:;
垂直水平居中
.parent{
position:relative;
height:300px;
width:300px;
background:red;
}
.child{
position:absolute;
height:50px;
width:50px;
background:green;
top:50%;
left:50%;
margin-top:-25px;
margin-left:-25px;
}
banner
//子元素的top,left值給的百分比是相對于父元素
html,body{
height:100%;
width:100%;
}
img{
height:指蚜;
width:;
position:absolute卸勺;
top:50%奸焙;
left:50%;
}
body{
position:relative献烦;
}
position:z-index;//z-index設(shè)置給了absolute定位元素的堆疊順序