简单的表格


<thread>包裹标题头<tbody>不包只用<tr><td>也行

  • <table class="table">
    为任意 <table> 添加基本样式 (只有横向分隔线)

<table class="table table-striped"> -----> <div class="table-striped"><table class="table">

image.png


  • <table class="table table-striped">
    在 <tbody> 内添加斑马线形式的条纹 ( IE8 不支持)
image.png

  • <table class="table table-bordered">
    为所有表格的单元格添加边框
image.png

  • <table class="table table-hover">
    在 <tbody> 内的任一行启用鼠标悬停状态

  • <table class="table table-condensed">
    让表格更加紧凑
image.png

  • <table class="table table-responsive class">
    可以让表格水平滚动以适应小型设备(小于 768px)。当在大于 768px 宽的大型设备上查看时,您将看不到任何的差别。

需要修改宽度的话怎么办?

style="width:40%"添加到<table>中,其他试了都无效。

<table class="table table-bordered table-striped table-hover table-condensed" style="width:30%">
  <caption>基本的表格布局</caption>
  <thead>
    <tr>
      <th width="10%">名称   其中名称和城市占位宽度1:2</th>  
      <th width="20%">城市</th>   
    </tr>
  </thead>

响应式表格:

通过把任意的 .table 包在 .table-responsive class 内,您可以让表格水平滚动以适应小型设备(小于 768px)。
<div class="table-responsive">
<table class="table">


如果需要更改悬浮时的颜色:

.table-hover > tbody > tr:hover > td,
.table-hover > tbody > tr:hover > th {
background-color: blue;
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容