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

div+css to create tables

WBOY
Release: 2018-09-28 10:15:41
Original
3458 people have browsed it

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>
Copy after login

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;}
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template