表格内容自适应css代码
表格内容自适应css代码,代码如下:
table {
border-collapse: collapse;
margin-bottom: 1rem;
}
table, table td, table th {
border: 1px solid rgba(170, 172, 182, 0.15)
}
table td, table th {
padding: 6px
}
table th {
background-color: #f8f9fa
}
table {
width: 100%!important;/*防止表格溢出*/
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
border-collapse: collapse;
border-color: #623F20;
border-image: none;
border-style: solid;
border-width: 1px 0 0 1px;
text-align: center;
}
table td, table th {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
border-color: #623F20;
border-image: none;
border-style: solid;
border-width: 0 1px 1px 0;
padding: 3px;
}或者是
table {
width: 100%; /* 设置表格宽度为100% */
border-collapse: collapse; /* 合并表格边框 */
margin-bottom: 1rem;
border: 1px solid rgba(170, 172, 182, 0.15); /* 设置表格边框 */
text-align: center; /* 设置表格文本居中对齐 */
}
table th {
background-color: #f8f9fa; /* 设置表头背景色 */
}
table td, table th {
border-color: #623F20; /* 设置单元格边框颜色 */
border-style: solid; /* 设置单元格边框样式 */
border-width: 0 1px 1px 0; /* 设置单元格边框宽度 */
padding: 6px; /* 设置单元格内边距 */
}
table th:first-child, table td:first-child {
border-left-width: 1px; /* 设置第一列单元格左边框宽度 */
}
table th:last-child, table td:last-child {
border-right-width: 1px; /* 设置最后一列单元格右边框宽度 */
}
table th:first-child {
border-top-width: 1px; /* 设置第一行表头上边框宽度 */
}
table th:last-child {
border-top-width: 1px; /* 设置最后一行表头上边框宽度 */
}
table td:first-child {
border-top-width: 1px; /* 设置第一列单元格上边框宽度 */
}
table td:last-child {
border-top-width: 1px; /* 设置最后一列单元格上边框宽度 */
}
table th:first-child, table th:last-child, table td:first-child, table td:last-child {
border-bottom-width: 1px; /* 设置表格最后一行下边框宽度 */
border-radius: 0; /* 取消表格圆角 */
}
