【发布时间】:2013-09-17 08:26:01
【问题描述】:
我有这张表,第一行有三个单元格。我正在尝试创建一个设计,如果没有空间,它将降低最后一个单元格。所以像上面的2,下面的1。随着窗口在每行上变得更小 1。我很难找到这样的东西。
我能够获得响应式设计,根据大小将所有单元堆叠在一起,但如果我能找到更好的解决方案,那就更好了。
HTML:
<table id="dashboard" cellpadding="0" cellspacing="0">
<tr>
<td id="TopLeft"><div class='chartLoadingOverlay'>Loading chart please be patient...</div></td>
<td id="TopRight"><div class='chartLoadingOverlay'>Loading chart please be patient...</div></td>
<td id="BottomLeft"><div class='chartLoadingOverlay'>Loading chart please be patient...</div></td>
</tr>
</table>
CSS:
#dashboard{
border-collapse: separate;
border-spacing: 5px 5px;
border: 5px solid red;
background-color: blue;
}
div.chartLoadingOverlay{
font-style:italic;
color:gray;
border:1px silver solid;
background-color:#F5F5F5;
line-height:250px;
height:250px;
width:500px;
text-align:center;
margin:2px;
}
@media only screen and (max-width: 1000px){
/* Force table to not be like tables anymore */
#dashboard table{
width: 100%;
border-collapse: collapse;
border-spacing: 0;
display: block;
position: relative;
width: 100%;
}
#dashboard tbody {
/*display: block;*/
width: auto; position: relative;
overflow-x: auto;
white-space: nowrap;
}
#dashboard tbody tr {
display: inline-block;
vertical-align: top;
}
#dashboard td {
display: block;
}
}
【问题讨论】:
-
您对浏览器有什么要求?另外,您的数据表格是表格吗,这就是为什么它需要在表格中(我问,因为如果不是,这更容易,和/或可以反向完成)
-
不,我的数据包含 Google API 图表。我使用表格是因为它是我操纵图表外观和位置的最简单方法。解决方案需要使用 IE8+
标签: html css responsive-design html-table