zoukankan      html  css  js  c++  java
  • 垂直水平居中的几种方法

    1,(元素在容器中垂直水平居中)
    css: .box{800px;height:800px;background:#ccc;display:flex;justify-content:center;align-items:center;}
                   .box div{300px;height:300px;background:red;}
    html:  <div class="box">
                   <div></div> 
              </div>
     
     
    2,(元素在容器中垂直水平居中)
    css: .box{800px;height:800px;background:#ccc;display:flex;justify-content:center;}
                   .box div{300px;height:300px;background:red;align-self:center;}
    html:  <div class="box">
                    <div></div> 
              </div>
     
     
    3,(元素在页面垂直水平居中)
    css:   .box{800px;height:800px;background:red;position:fixed;left:0;right:0;top:0;bottom:0;margin:auto;}
    html:  <div class="box"></div>
     
     
    4,(元素在容器中垂直水平居中)
    css:    .box{800px;height:800px;text-align:center;}
              .box .box2{display:inline-block;vertical-align:middle;}
              .box span{display:inline-block;0px;height:100%;vertical-align:middle;}
    html:   <div class="box">
                       <a class="box2">垂直水平居中</a><span></span>                    
               </div>
               <!--要在元素后面不换行加空的span-->
    不问前程凶吉,但求落幕无悔
  • 相关阅读:
    2017ecjtu-summer training # 9 HDU 4544
    2017ecjtu-summer training #6 Gym 100952D
    HDU 1241 DFS
    集训队选拔赛 day4
    Educational Codeforces Round 67 (Rated for Div. 2)
    Codeforces Round #566 (Div. 2)
    Codeforces Round #567 (Div. 2)
    Codeforces Round #568 (Div. 2)
    Codeforces Round #569 (Div. 2)
    牛客练习赛48
  • 原文地址:https://www.cnblogs.com/qiao915/p/6627982.html
Copyright © 2011-2022 走看看