
2020-08-21_093049.png
一下有兩種辦法可以實(shí)現(xiàn),而且比較簡(jiǎn)單:
方法1 :定位:
<style>
div{
width:400px;
height:400px;
background:red;
position: relative;
margin:100px 0 0 100px;
}
p{
width:200px;
height:200px;
background:cornflowerblue;
position: absolute;
top:100px;
left:100px;
}
</style>
<body>
<div>
<p> </p>
</div>
</body>
方法二、使用css3位移的方式:
<style>
div{
width:400px;
height:400px;
background:red;
}
p{
width:200px;
height:200px;
background:cornflowerblue;
transform: translate(100px,100px);
}
</style>
<body>
<div>
<p></p>
</div>
</body>
網(wǎng)上還有很多的方法,如有問(wèn)題,歡迎指出?。。。?!