在高度不确定的情况下让div自身垂直和水平局中的终极解决方案(CSS3写法)

<div class='contain' ></div>

<style>
.contain {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 600px;
  height: auto;
  transform: translateX(-50%) translateY(-50%);
}
</style>

  

posted @ 2022-01-02 21:08  专注网站建设和推广  阅读(43)  评论(0)    收藏  举报