Why is is top:50% in css not working?

后端 未结 7 1681
野性不改
野性不改 2021-02-03 22:30

I am making a website and I\'m trying to vertically center:

 position: absolute;
 width:1200px;
 height:600px;
 top: 50%;
 left: 50%;
 margin-left: -600px;


        
相关标签:
7条回答
  • 2021-02-03 23:08

    I think this should be helpful :)

    i{
      -webkit-transform: translate(-50%,-50%);
      transform: translate(-50%,-50%);
      position: absolute;
      top: 50%;
      left: 50%;
    }
    <i>center</i>

    0 讨论(0)
提交回复
热议问题