轉載:html,將元素水平,垂直居中的四種方式

  將元素垂直,水平居中分兩種情況:一個是元素尺寸固定,二是元素尺寸不固定 一.尺寸固定 方法1:定位 ,50%,margin負距   .box{ width: 400px; height: 300px; border: 2px solid black; /* 把元素變成定位元素 */ position: absolute; /* 元素距離上,左都爲50% */ left: 50%; top: 5
相關文章
相關標籤/搜索