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>    

       

          

        

          

          

  • 相关阅读:
    c++ namespace简单用法
    python2编码问题
    python dict()函数 /// logging模块///yield//生成器和迭代器
    python 对于一个字典,根据其value值获取其对应的keys值
    python 包/库/模块
    python __init()__
    python continue 和 break的区别
    python list去重
    linux命令,将一个文件夹中的内容copy到另外一个文件夹
    python 正则(re.compile()/re.findall())
  • 原文地址:https://www.cnblogs.com/byronvis/p/4506770.html
Copyright © 2011-2022 走看看