Positioning
element at center of screen

后端 未结 13 1426
死守一世寂寞
死守一世寂寞 2020-11-28 18:34

I want to position a

(or a ) element at the center of the screen irrespective of screen size. In other words, the space le
13条回答
  •  日久生厌
    2020-11-28 19:12

    I would do this in CSS:

    div.centered {
      position: fixed; 
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    

    then in HTML:

提交回复
热议问题