css元素水平垂直居中的方式

實現方法 1、 margin:auto; position: absolute; left: 0; right: 0; top: 0; bottom:0; 此代碼會使任意子元素相對最近有定位的父元素水平垂直居中。 顯示效果: 2、 position: absolute; left: 50%; top: 50%; margin-top:-xxpx;(xx=height/2) margin-left:
相關文章
相關標籤/搜索