css实现元素垂直居中
in 前端 with 0 comment

css实现元素垂直居中

in 前端 with 0 comment
parentElement{
        position:relative;
    }

 childElement{
        position: absolute;
        top: 50%;
        transform: translateY(-50%);

 }

作者:Jaskey Lam
来源:https://www.zhihu.com/question/20543196/answer/57757836

补充:在项目中用到这个本来是想垂直居中并且隐藏多余的字符,发现部分情况下会有异常...

Comments are closed.