body { margin:0; padding: 0; display: flex; flex-wrap: wrap; height: 930px; } .table-container{ flex:0.6; padding:10px; background-color: #fff; min-width:100px; box-sizing: border-box; border: 0.5px solid #999; color: #333; box-shadow: 0px 0px 20px rgba(0,0,0,1); } th,td{ padding:5px; border: 1px solid #ccc; } th{ background: linear-gradient(to bottom,#f2f2f2 0%,#d4d4d4 100%); font-weight: bold; } .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 22:03:15 浏览: 72
rehype-wrap:用给定元素包装所选元素
可以尝试以下代码实现:
```html
<body>
<div class="table-container">
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
<td>Row 1, Column 3</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
<td>Row 2, Column 3</td>
</tr>
<tr>
<td>Row 3, Column 1</td>
<td>Row 3, Column 2</td>
<td>Row 3, Column 3</td>
</tr>
</tbody>
</table>
</div>
<div class="graph-container">
<div class="graph"></div>
<div class="graph"></div>
</div>
</body>
<style>
body {
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
height: 930px;
}
.table-container {
flex: 0 1 100%;
padding: 10px;
background-color: #fff;
min-width: 100px;
box-sizing: border-box;
border: 0.5px solid #999;
color: #333;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 1);
}
table {
width: 100%;
border-collapse: collapse;
}
th,
td {
padding: 5px;
border: 1px solid #ccc;
}
th {
background: linear-gradient(to bottom, #f2f2f2 0%, #d4d4d4 100%);
font-weight: bold;
}
.graph-container {
flex: 0 1 100%;
padding: 10px;
background-color: #f0f0f0;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
align-items: left;
justify-content: left;
}
.graph {
flex: 0 1 45%;
height: 300px;
margin: 10px;
background-color: #ccc;
border: 1px solid #999;
}
@media screen and (max-width: 1200px) {
.graph {
flex-basis: 45%;
}
}
@media screen and (max-width: 800px) {
.graph {
flex-basis: 90%;
}
}
</style>
```
在上述代码中,我们使用了 `flex` 布局来实现所需的布局。具体来说,我们将表格容器的宽度设为 `flex: 0 1 100%`,即占用整个可用宽度,并且不能缩小,高度为自适应。同时,我们将下方的图表容器的宽度也设为 `flex: 0 1 100%`,以占用整个可用宽度。对于图表容器中的每个图表,我们将其宽度设为 `flex: 0 1 45%`,以占用父容器的45%宽度,并留出一定的间距。在不同的屏幕尺寸下,我们使用媒体查询来调整图表容器中每个图表的宽度,以实现响应式布局。
阅读全文