html中table樣式設(shè)置

小億
201
2023-12-20 18:22:25

HTML中可以使用CSS來(lái)設(shè)置table的樣式。以下是一些常用的table樣式設(shè)置:

  1. 設(shè)置表格的邊框樣式:
table {
  border-collapse: collapse;
  border: 1px solid black;
}
  1. 設(shè)置表格的寬度和高度:
table {
  width: 100%;
  height: 200px;
}
  1. 設(shè)置表格的背景顏色:
table {
  background-color: #f2f2f2;
}
  1. 設(shè)置表格中單元格的邊框樣式:
td, th {
  border: 1px solid black;
}
  1. 設(shè)置表格的字體樣式:
table {
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: #333333;
}
  1. 設(shè)置表頭的背景顏色和文字顏色:
th {
  background-color: #333333;
  color: #ffffff;
}
  1. 設(shè)置表格中的奇偶行的背景顏色:
tr:nth-child(odd) {
  background-color: #f9f9f9;
}
  1. 設(shè)置表格中鼠標(biāo)懸停時(shí)的背景顏色:
tr:hover {
  background-color: #dcdcdc;
}

以上是一些常用的table樣式設(shè)置,可以根據(jù)具體需求進(jìn)行調(diào)整和擴(kuò)展。

0