Horizontal centering text over image via CSS

前端 未结 5 664
长情又很酷
长情又很酷 2020-12-08 07:42

Consider the following html:

Text of variable length
5条回答
  •  不知归路
    2020-12-08 08:07

    Using Flex is a more"flexible" option :-)

    #countdown {
      font-size: 100px;
      z-index: 10;
    }
    
    #countdown-div {
      width: 100vw;
      height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    #bg-image {
      width: 100vw;
      height: 100vh;
      position: absolute;
      top: 0px;
      left: 0px;
    }
    

    10

提交回复
热议问题