使用table,如何讓中的內容 水平居中同時垂直居中


 

給標簽設置text-align以及line-height屬性

如果line-height不加important的話,就不會垂直居中,因為table自帶的一些屬性會影響我們設置的line-height

    <style>
        td, tr,th{
            text-align: center;
        }
        td{
            line-height: 34px !important;
        }

    </style>

效果如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM