使一个我自址哈这工边识框处己按后大都加控不架的div居中显示比抖朋要插支一圈不者地器享说几的三种方法
1.
div居中/*第一种方法*/
div{
width: 200px;
height: 200px;
background-color: orchid;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
div居中/*第二种方法*/
div{
width: 200px;
height: 200px;
position: absolute;
background-color: orchid;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -100px;
}
使需朋者说上事是础一发一开程和开数的目前间div2在div1里面新直能分支调二浏页器朋代说,事刚居中显示
div居中/*第三种方法*/
#div1 {
width: 700px;
height: 600px;
background-color: orange;
display: flex;
align-items: center;
justify-content: center;
}
#div2 {
width: 200px;
height: 200px;
background-color: orchid;
}
本文来源于网络:查看 >https://blog.csdn.net/weixin_43885123/article/details/84864404