body { margin:0; padding: 0; display: flex; flex-wrap: wrap; height: 930px; } .table-container{ flex:0.5; padding: 10px; background-color: #f7f7f7; min-width: 100px; box-sizing: border-box; border: 2px solid #999; } .graph-container{ flex: 1; padding: 10px; background-color: #f0f0f0; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: left; justify-content: left; } .graph{ width: 45%; height: 300px; margin: 10px; background-color: #ccc; border: 1px solid #999; } @media screen and (max-width: 1200px){ .graph{ width: 45%; } } @media screen and (max-width: 800px){ .graph{ width:90%; } } 优化表格容器 使表格内容居中 突出显示表格的边框 且边框只包含到表格的内容
时间: 2024-01-11 17:03:07 浏览: 135
可以尝试添加以下样式:
.table-container {
display: flex;
justify-content: center;
align-items: center;
border-collapse: collapse; /* 去掉表格边框之间的间隙 */
border: 2px solid #999;
}
.table-container td,
.table-container th {
border: 1px solid #999;
padding: 10px;
}
.table-container th {
background-color: #f7f7f7;
font-weight: bold;
}
.table-container tr:first-child th { /* 突出显示表头 */
border-top: 2px solid #999;
}
.table-container tr:last-child td { /* 突出显示表格底部边框 */
border-bottom: 2px solid #999;
}
```
需要注意的是,这里的样式只是基础样式,需要根据具体的表格结构和需求进行修改。
相关问题
body { margin:0; padding: 0; display: flex; flex-wrap: wrap; height: 930px; } .table-container{ display: flex; justify-content: center; align-items: center; border-collapse: collapse; border: 2px solid #999; } .graph-container{ flex: 1; padding: 10px; background-color: #f0f0f0; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: left; justify-content: left; } .graph{ width: 45%; height: 300px; margin: 10px; background-color: #ccc; border: 1px solid #999; } @media screen and (max-width: 1200px){ .graph{ width: 45%; } } @media screen and (max-width: 800px){ .graph{ width:90%; } 修改代码 让表格容器占页面的三分之一
可以将.table-container的flex属性改为flex: 1 0 33.33%;,这样就可以让表格容器占据页面的三分之一了。代码如下:
```
body {
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
height: 930px;
}
.table-container {
display: flex;
justify-content: center;
align-items: center;
border-collapse: collapse;
border: 2px solid #999;
flex: 1 0 33.33%;
}
.graph-container {
flex: 1;
padding: 10px;
background-color: #f0f0f0;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
align-items: left;
justify-content: left;
}
.graph {
width: 45%;
height: 300px;
margin: 10px;
background-color: #ccc;
border: 1px solid #999;
}
@media screen and (max-width: 1200px) {
.graph {
width: 45%;
}
}
@media screen and (max-width: 800px) {
.graph {
width: 90%;
}
}
```
body { margin:0; padding: 0; display: flex; flex-wrap: wrap; height: 930px; } .table-container{ flex:0.5; padding: 10px; background-color: #f7f7f7; min-width: 100px; box-sizing: border-box; border: 2px solid #999; } .graph-container{ flex: 1; padding: 10px; background-color: #f0f0f0; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: left; justify-content: left; } .graph{ width: 45%; height: 300px; margin: 10px; background-color: #ccc; border: 1px solid #999; } @media screen and (max-width: 1200px){ .graph{ width: 45%; } } @media screen and (max-width: 800px){ .graph{ width:90%; } } 优化表格容器 使表格更好看
可以尝试修改以下样式,来优化表格容器,使表格更好看:
```
.table-container{
flex: 0.5;
padding: 10px;
background-color: #f7f7f7;
min-width: 100px;
box-sizing: border-box;
border: 2px solid #999;
border-radius: 5px;
overflow: auto;
}
```
在原有的样式基础上,添加 `border-radius` 属性可以让表格容器拥有圆角边框,让视觉效果更加友好。同时,添加 `overflow` 属性,可以让表格内容超出容器部分自动滚动,避免溢出造成页面混乱。
阅读全文