bootstrap入门【表格】

本文介绍如何利用Bootstrap框架来美化HTML表格的样式,并实现响应式布局。通过不同的类设置表格样式,如斑马线效果、边框样式、鼠标悬停高亮等。同时展示了如何为表格单元格设置不同颜色。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


<link href="bootstrap.min.css" rel="stylesheet">  导入bootstrap的外部样式表

<thead>
    <tr>
        <th>表格标题</th>
        <th>表格标题</th>
        <th>表格标题</th>
    </tr>
</thead>      表头

<tbody>
    <tr class="info">
        <th>表格单元格</th>
        <th>表格单元格</th>
        <th>表格单元格</th>
    </tr>
</tbody>      表格内容

table-striped  斑马线
table-bordered   边框
table-hover     鼠标响应
table-condensed   浓缩布局
table-responsive   在div中,响应式布局


单元格颜色:
class="info"   蓝色
class="danger"  红色
class-="warning"  黄色
class="active"  选中
class="success"  绿色


<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link href="bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="table-responsive">
        <!--<table class="table table-striped table-bordered table-hover table-condensed">-->
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>表格标题</th>
                    <th>表格标题</th>
                    <th>表格标题</th>
                </tr>
            </thead>
            <tbody>
                <tr class="info">
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                </tr>
                <tr class="danger">
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                </tr>
                <tr class-="warning">
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                </tr>
                <tr class="active">
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                </tr>
                <tr class="success">
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                    <th>表格单元格</th>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值