垂直水平置中

來源:互聯網
上載者:User

垂直水平置中


這是body代碼

  1. 垂直水平置中


解析:父元素relative 子項目absolute,子項目設定寬高,top和left設定為50%,margin-top和margin-left設定為高寬的一半乘以-1.

2.水平置中:

方法1:margin: 0 auto;

方法2:

解析:父元素relative,子項目absolute,子項目設定寬度,left:50%;margin-left:寬度的一半乘以-1;

3.垂直置中:

解析:父元素relative,子項目absolute,子項目設定高度,top:50%;margin-top:寬度的一半乘以-1;

  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.