CSS-Table

首先说明:<th>列(字体会加粗),<td>列,<tr>行

1.普通表格

<style>
table, th, td {
border: 1px solid black;
}
</style>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>

双边框.JPG

2.合并边框

table {
    border-collapse: collapse;
}

table, td, th {
    border: 1px solid black;
}
</style>
单边框.JPG

3.合并里面线

<style>
table {
    border-collapse: collapse;
    border: 1px solid black;
}
</style>
合并里面.JPG

4.Table Width and Height

<style>
table, td, th {
    border: 1px solid black;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th {
    height: 50px;
}
</style>
宽和高.JPG

5.水平对齐

<style>
table, td, th {
    border: 1px solid black;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th {
    text-align: left;
}
左对齐.JPG
<style>
table, td, th {
    border: 1px solid black;
}

table {
    border-collapse: collapse;
    width: 100%;
}

td {
    height: 50px;
    vertical-align: bottom;
}
</style>
底对齐.JPG

6.Table Padding

<style>
table, td, th {    
    border: 1px solid #ddd;
    text-align: left;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 15px;
}
</style>
padding.JPG

7.水平分规

<style>
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
</style>
t2.JPG

8.鼠标经过有东西的表格

<style>
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

tr:hover{background-color:#f5f5f5}
</style>
t3.JPG

9.有条纹的表格

<style>
table {
    border-collapse: collapse;
    width: 100%;
}
th, td {
    text-align: left;
    padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
</style>
条纹.JPG
  • 加上背景色
<style>
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    text-align: left;
    padding: 8px;
}

tr:nth-child(even){background-color: #f2f2f2}

th {
    background-color: #4CAF50;
    color: white;
}
</style>
背景色.JPG

10.响应时表格

<style>
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {[图片上传中...(拉动.JPG-cc9f7-1533173680116-0)]

    text-align: left;
    padding: 8px;
}

tr:nth-child(even){background-color: #f2f2f2}
</style>
拉动.JPG
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.预热 css样式多如牛毛,我不可能一个一个去讲,那样好像背字典一样,我相信你们也不喜欢这样的方式。所以,我会在...
    剽悍一小兔阅读 5,368评论 0 17
  • border-collapse属性 border-spacing属性 这个在table中设置, 是设置table中...
    遥望泰山阅读 3,142评论 0 0
  • 关于Mongodb的全面总结 MongoDB的内部构造《MongoDB The Definitive Guide》...
    中v中阅读 32,177评论 2 89
  • table-cell table-cell 具有“同行等高,同行各列自动调节宽度”的特性。因此可以用于响应式布局 ...
    栗子酥小小阅读 5,154评论 0 0
  • 我喜欢爬到高山峻岭,尽管有时被惊险充满了不确定性,而且又特别喜欢走上山,这不为别的,只为自己能够跳出山峰看山...
    TeenXie阅读 5,063评论 1 1

友情链接更多精彩内容