.king{
margin-top: 30px;
margin-left: 30px;
border: 1px solid silver;
background-color: skyblue;
width: 40%;
}
.king div{
width: 100px;
height: 60px;
margin: 10px;
background-color: snow;
color: black;
border: 1px solid black;
}
.three{
position: relative;
top: 20px;
left: 50px;
}
one
two
three
four
固定定位
被固定的元素不会随着滚动条的拖动而改变位置。
position:fixed;
在默认情况下,固定定位元素的位置是相对浏览器而言,结合top、bottom、left和right这4个属性一起使用。
div元素
固定定位的div元素
绝对定位
position:absolute;
默认情况下,绝对定位的位置是相对于浏览器而言,配合top、right、bottom、left进行定位。