zoukankan      html  css  js  c++  java
  • 没有宽高的情况下实现水平垂直居中

    一、

    .main {
        width: 300px;
        height: 500px;
        background-color: #50ba8b;
        
    
        position: relative;
       }
     
    .content {
        width: 100px;
        height: 100px;
        background-color: #5b4d4e;
     
    
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        margin: auto;
    }

    二、

    .main {
        width: 300px;
        height: 300px;
        background-color: #50ba8b;
        
    
        position: relative;
    }
     
    .content {
        width: 150px;
        height: 150px;
        background-color: #5b4d4e;
     
    
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    三、

    .main {
        width: 300px;
        height: 300px;
        background-color: #50ba8b;
     
    
        display: flex;
      }
     
      .content {
        width: 150px;
        height: 150px;
        background-color: #5b4d4e;
     
    
        margin: auto;
     }

    四、

    .content {
         width: 150px;
         height: 150px;
         background-color: #5b4d4e;
     
         /*关键代码*/
         display: flex;
         align-items: center;
         justify-content: center;
         margin: auto;
        }
    <div class="content">
        <div>12313</div>   
    </div>
  • 相关阅读:
    spring-ioc
    Hibernate之二级缓存
    hibernate之HQL语句
    hibernate 多对多关联关系
    hibernate关联关系(一对多)
    Hibernate之主键生成策略
    struts2的CRUD
    struts2的OGNL
    struts2的初步认识
    Maven介绍
  • 原文地址:https://www.cnblogs.com/mengzekun/p/11537679.html
Copyright © 2011-2022 走看看