Home >Web Front-end >CSS Tutorial >div+css to create tables

div+css to create tables

WBOY
WBOYOriginal
2016-05-16 12:10:173459browse

This chapter introduces how to use div+css to create tables. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

html:

    <p class="table">  
        <h2 class="table-caption">花名册:</h2>  
        <p class="table-column-group">  
            <p class="table-column"></p>  
            <p class="table-column"></p>  
            <p class="table-column"></p>  
        </p>  
        <p class="table-header-group">  
            <ul class="table-row">  
                <li class="table-cell">序号</li>  
                        <li class="table-cell">姓名</li>  
                        <li class="table-cell">年龄</li>  
            </ul>  
        </p>  
        <p class="table-footer-group">  
            <ul class="table-row">  
                <li class="table-cell">footer</li>  
                <li class="table-cell">footer</li>  
                <li class="table-cell">footer</li>  
            </ul>  
        </p>  
        <p class="table-row-group">  
            <ul class="table-row">  
                <li class="table-cell">1</li>  
                <li class="table-cell">John</li>  
                <li class="table-cell">19</li>  
            </ul>  
            <ul class="table-row">  
                <li class="table-cell">2</li>  
                <li class="table-cell">Mark</li>  
                <li class="table-cell">21</li>  
            </ul>  
            <ul class="table-row">  
                <li class="table-cell">3</li>  
                <li class="table-cell">Kate</li>  
                <li class="table-cell">26</li>  
            </ul>  
        </p>  
    </p>

css:

ul{margin:0;padding:0;list-style:none;}  
.table{display:table;border-collapse:collapse;border:1px solid #ccc;}  
.table-caption{display:table-caption;margin:0;padding:0;font-size:16px;}  
.table-column-group{display:table-column-group;}  
.table-column{display:table-column;width:100px;}  
.table-row-group{display:table-row-group;}  
.table-row{display:table-row;}  
.table-row-group .table-row:hover,.table-footer-group .table-row:hover{background:#f6f6f6;}  
.table-cell{display:table-cell;padding:0 5px;border:1px solid #ccc;}  
.table-header-group{display:table-header-group;background:#eee;font-weight:bold;}  
.table-footer-group{display:table-footer-group;}

The above is all the code for making a table using div+css. You can try it yourself.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn