
一下有两种办法可以实现,而且比较简单:
方法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>
网上还有很多的方法,如有问题,欢迎指出!!!!!
网友评论