zoukankan      html  css  js  c++  java
  • 水平垂直居中(固定宽不固定宽)

    1、水平垂直居中

    方法一:使用absolute定位的时候,元素脱离文档流,导致margin:auto;失效,需要配合使用left:0;right:0;top:0;bottom:0;

    <div class="box">
        <div class="center-middle"></div>
    </div>
    
    .box{
        position:relative;
        300px;
        height:300px;
        background-color:yellow;
        
    }
    .center-middle {
        100px;
        height:100px;
        position:absolute;
        left:0;
        right:0;
        top:0;
        bottom:0;
        margin:auto;
        background-color:#ccc;
    }
  • 相关阅读:
    iPhone iPad发展史
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
  • 原文地址:https://www.cnblogs.com/qdlhj/p/9094547.html
Copyright © 2011-2022 走看看