1 position: relative;
2 top: 10px;
3 left: 40px;
1 position: relative;
2 right: 100px; → 往左边移动
3 top: 100px;
1 position: relative;
2 right: 100px;
3 bottom: 100px; → 移动方向是向上。
1 position: relative;
2 top: -200px; → 负数就是相反的方向,如果是正,就是下边,如果是负数就是上边
3 right: -200px;
1 position: relative;
2 right: -300px;
3 bottom: 300px;
4 position: relative;
5 left: 300px;
1 bottom: 300px;
1 position:relative;
2 top:100px;
3 left:200px;
1 position:relative;
2 bottom:-100px;
3 right:-200px;
1 position:relative;
2 top:100px;
3 right:-200px;
1 position:relative;
2 bottom:-100px;
3 left:200px;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
div{
width: 200px;
height: 200px;
}
.box1{
background-color: yellowgreen;
}
.box2{
background-color: skyblue;
position: absolute;
top: 100px;
left: 140px;
}
.box3{
background-color: gold;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style type="text/css">
span{
position: absolute;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
background-color: pink;
}
</style>
</head>
<body>
<span></span>
</body>
</html>
1 span{
2 position: absolute;
3 top: 100px;
4 left: 100px;
5 width: 100px;
6 height: 100px;
8 }