zoukankan      html  css  js  c++  java
  • CSS水平垂直居中

    水平居中

    • 文本居中
             <style>
    
            div{
              text-aligh:center
            }
    
          </style>            

        

    • 元素居中

          1,margin法    

          <style>
    
            div{
              width:300px;
              margin:0 auto;
            }
    
          </style>

          2,position法     

          <style>
    
            div{
              position:absolute;
              width:300px;
              left:50%;
              margin-left:-150px;
            }
    
          </style>

    垂直居中

    • 文本居中

          1,单行文本居中 

          <style>
    
            div{
              height:30px;
              line-height:30px;
            }
    
          </style>

          2,多行文本居中    

          <style>
    
            div{
             padding:30px 0;
            }
    
          </style>
    • 元素居中

          1,position法    

          <style>
    
            div{
              position:absolute;
              top:50%;
              height:300px;
              margin-top:-150px;
            }
    
          </style>

         

           2,table法   

     

    <style>
    
            div{
                   display:table
            }
    
            div span{
                display:table-cell;
                vertical-align:middle;
            }
    
    </style>    

       

          

        

          

          

  • 相关阅读:
    Go基础数据类型
    在foreach中使用distinct查找不重复记录
    DataTable,List去重复记录的方法(转载)
    ArcEngine的IMap接口(转载)
    根据Excel表格建立Shp文件(开发详解及源代码)(转载)
    axmapcontrol和mapcontrol有什么区别呢(转发)
    DataSet多表查询操作(转载)
    c#调用DLL(转载)
    wall 系列技术贴
    ArcEngine的IFeaturLayer接口(转载)
  • 原文地址:https://www.cnblogs.com/byronvis/p/4506770.html
Copyright © 2011-2022 走看看