DIV屏幕居中

2018-11-27  本文已影响7人  知足常乐晨

mark一下

方法一

.main{
    width: 300px;
    height: 350px;
    margin: auto;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

方法二

.main{
    width: 300px;
    height: 350px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
}
上一篇 下一篇

猜你喜欢

热点阅读