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>    

       

          

        

          

          

  • 相关阅读:
    数据的独立同分布检验
    基于密度聚类的DBSCAN和kmeans算法比较
    Python 爬虫笔记、多线程、xml解析、基础笔记(不定时更新)
    多进程之multiprocessing模块、守护进程、互斥锁
    程序与进程的区别,并发与并行的区别,多进程的实现原理
    并发编程之守护进程
    MySQL帮助文档的使用
    MySQL操作之DCL
    MySQL操作之DML
    MySQL操作之DDL
  • 原文地址:https://www.cnblogs.com/byronvis/p/4506770.html
Copyright © 2011-2022 走看看