Why does auto attribute for margin not work vertically while it works horizontally?

后端 未结 3 899
鱼传尺愫
鱼传尺愫 2020-12-08 08:28

I have seen that while developing websites, vertically centering a container (of fixed height) inside a container of random height always comes as a nightmare for the web de

3条回答
  •  情歌与酒
    2020-12-08 08:53

    css ----------------

    .aligncenter{
          display: -webkit-box;
          display: -moz-box;
          display: box;
          -webkit-box-align: center;
          -moz-box-align: center;
          flex-align: center;
          -webkit-box-pack: center;
          -moz-box-pack: center;
          flex-pack: center;
    }
    

    html -------------------------

    ---your content appear at the middle of the parent div----

    note----------- this css class work with almost all browsers

提交回复
热议问题