表格边框
使用border属性设置表格边框
table,th,td {
border:1px solid black;
}
第一个参数是边框的粗细大小,第二个参数是边框的样子,实线还是虚线等。第三个参数是边框的颜色
折叠边框
使用border-collapse属性可以把表格边框折叠为单一边框
table,th,td {
border:1px solid black;
}
table {
border-collapse: collapse;
}
表格宽度和高度
使用weidth和height属性定义表格的宽度和高度
table,th,td {
border:1px solid black;
}
table {
border-collapse: collapse;
width:25%;
}
th {
height:40px;
}
表格的百分之好像是按照屏幕大小来算的。
表格文本对齐
使用text-align属性设置水平对齐方式,vertical-align属性设置垂直对齐方式
td {
text-align: center;
vertical-align: bottom;
}
表格内边距
使用padding属性控制表格中内容与边框的距离
td {
text-align: center;
vertical-align: bottom;
padding:15px;
}
表格颜色
color:表格内文字的颜色
background-color:表格的背景颜
th {
height:40px;
color:red;
background-color: green;
}