• 元素水平垂直居中的方式有哪些


    元素水平垂直居中的方式有哪些?

    • absolute加margin方案

    • fixed 加 margin 方案

    • display:table 方案

    • 行内元素line-height方案

    • flex 弹性布局方案

    • transform 未知元素宽高解决方案

    • 
      
      absolute加margin方案
      
      
          div{
              position: absolute;
               100px;
              height: 100px;
              left: 50%;
              top: 50%:
              margin-top: -50px;
              margin-left: -50px;
          }
      
      
      fixed 加 margin 方案
      
      
          div{
              position: fixed;
               100px;
              height: 100px;
              top: 0;
              right:0;
              left: 0;
              bottom: 0;
              margin: auto;
          }
      
      
      display:table 方案
      
      
          div{
              display: table-cell;
              vertical-align: middle;
              text-align: center;
               100px;
              height: 100px;
          }
      
      
      行内元素line-height方案
      
      
          div{
              text-align: center;
              line-height: 100px;
          }
      
      
      flex 弹性布局方案
      
      
          div{
              display: flex;
              align-items: center;
              justify-content:center
          }
      
      
      transform 未知元素宽高解决方案
      
      
          div{
              position: absolute;
              top: 50%;
              left: 50%;
              transform: translate(-50%, -50%)
          }
       
  • 相关阅读:
    3.nginx反向代理服务器+负载均衡
    2.nginx整合PHP
    nginx-location rewrite
    Nginx(一):安装
    修改host文件原理 localhost,127.0.0.1之间有什么区别
    一个IP绑定多个域名
    私有IP
    转:Hadoop和Spark的异同
    C#中Trim()、TrimStart()、TrimEnd()的用法
    Java操作redis
  • 原文地址:https://www.cnblogs.com/Xuman0927/p/12056932.html
Copyright © 2020-2023  润新知