08:CSS设置表格样式

12 篇文章 0 订阅

1.一个简单的表格
table.html

<!doctype html>
<html>
<head>
  	<meta charset="utf-8">
  	<title>表格样式</title>
    <link href="box.css" type="text/css" rel="stylesheet">
</head>
<body>
  <center>
  <table class="class">
      <caption>课程表</caption>
      <thead>
        <tr>
            <th>星期\课程</th>
            <th>星期一</th>
            <th>星期二</th>
            <th>星期三</th>
            <th>星期四</th>
            <th>星期五</th>
      </tr>
      </thead>
      <tbody>
      <tr>
            <th>1-2节</th>
            <td>数学</td>
            <td>语文</td>
            <td>化学</td>
            <td>英语</td>
             <td>英语</td>
      </tr>

      <tr>
            <th>3-4节</th>
            <td>英语</td>
            <td>物理</td>
            <td>化学</td>
            <td>英语</td>
             <td>体育</td>
      </tr>
      
      <tr>
            <th>5-6节</th>
            <td>数学</td>
            <td>物理</td>
            <td>体育</td>
            <td>化学</td>
            <td>美术</td>
      </tr>

      <tr>
            <th>7-8节</th>
            <td>数学</td>
            <td>美术</td>
            <td>化学</td>
            <td>英语</td>
            <td>体育</td>
      </tr>
      <tr>
            <th>9-10节</th>
            <td>生物</td>
            <td>美术</td>
            <td>生物</td>
            <td>英语</td>
            <td>物理</td>
      </tr>
      </tbody>
    </table>
  </center>
  </body>
</html>

table.css

table,td,th{
	border:1px solid #aaa;
	font-size: 23px;
	
}

2.边框合并:boder-collapse
属性值:
separate;(分开,默认)
collapse;(合并)

table.css

table,td,th{
	border:1px solid #aaa;
	font-size: 23px;
	border-collapse:collapse;
}

3.边框间距border-spacing(前提是:border-collapse:separate;)

table.css

table,td,th{
	border:1px solid #aaa;
	font-size: 23px;
	border-collapse:separate;
	border-spacing: 45px;
}

4.设置表格标题的位置caption-side
属性值:
top;//默认
bottom;
left;
right;

table.css

table,td,th{
	border:1px solid #aaa;
	font-size: 23px;
	border-collapse:separate;
	border-spacing: 45px;
	caption-side:bottom;
}

5.当单元格对象宽度超过单元格所定义的宽度时,可用table-layout:fixed保持表格宽度不被改变
属性值:auto(默认)
fixed(宽度固定)
table.css

table,td,th{
	border:1px solid #aaa;
	font-size: 23px;
	border-collapse:separate;
	border-spacing: 5px;
	table-layout: fixed;
	caption-side:top;

}
19:30 2018/8/17/周五
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值