zoukankan      html  css  js  c++  java
  • 不设宽高垂直居中

    第一种

    .div{
        position: absolute;
        top: 50%;
        left: 50%;
        z-index: 3;
        transform: translate(-50%,-50%);
    }

    第二种:

    .div{
        justify-content: center;
        align-items: center;
        display: -webkit-flex;
    }

    第三种:

    .div{

      display:absolute;
      left:50%;
      top:50%;
      margin-left:-width/2;//负向偏移宽度的一半,如果width不定,需要动态获取。
      margin-top:-height/2;//原理同上

    }

  • 相关阅读:
    Day10
    Day9
    Day8
    Day7
    Day 6
    Day5
    第一周计划
    事件总线模式辨析
    解释器模式辨析
    解释器模式深度探究
  • 原文地址:https://www.cnblogs.com/Byme/p/5807536.html
Copyright © 2011-2022 走看看