效果图:
dom布局:
1.使用flex布局
设置父容器:display:flex;justify-content:center;aligin-item:center;
2:绝对定位+margin
3.绝对定位+transfrom
4.absolute+top+left+bottom+right+margin
设置要居中的元素为绝对定位,top,left,bottom,right值均为0,margin:auto;
设置父容器:display:flex;justify-content:center;aligin-item:center;
设置要居中的元素为绝对定位,top,left,bottom,right值均为0,margin:auto;
本文标题:实现元素水平垂直居中
本文链接:https://www.haomeiwen.com/subject/xnizqqtx.html
网友评论