【发布时间】:2017-12-22 05:27:22
【问题描述】:
我有一个包含 3 列的表格(用于显示专辑歌曲)。编号、曲目标题和艺术家。我想保持 Number 和 Artist 列较小,并允许 Title 放置该列的大部分空间。我想让它响应移动设备。
我设法用white-space: nowrap、overflow: auto 使它正确,并在表td 中添加max-width。这在具有大显示屏的桌面上看起来不错,但在移动屏幕中,table 中使用的width:100% 似乎不适用,因为表格超出了屏幕的限制。
如何修复它并在小屏幕上显示完整的表格?只有@media才有可能吗?
完成的工作在这里:
table {
width: 100%;
}
table th {
background: #E4E4E4;
line-height: 23px;
padding-top: 6px;
color: #626262;
letter-spacing: 0.05em;
text-transform: uppercase;
font-size: 11px;
border: 1px solid #DBDBDB;
}
table td {
font-size: 13px;
line-height: 22px;
background: #F7F7F7;
border-top: 1px solid #F3F3F3;
white-space: nowrap;
overflow: auto;
max-width: 300px;
}
table td,
table th {
text-align: left;
padding: 3px 20px;
}
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<th>Nº</th>
<th class="largura-min">Title</th>
<th>Artist</th>
</tr>
<tr>
<td>1</td>
<td>I need this column placing most of this space / Superlong String Superlong String Superlong String Superlong String Superlong String Superlong String Superlong String Superlong String Superlong String Superlong String</td>
<td>ARTIST</td>
</tr>
<tr class="even">
<td>2</td>
<td>TITLE 2</td>
<td>I NEED A SMALLER ARTIST SPACE / SUPERLONG ARTIST SUPERLONG ARTIST SUPERLONG ARTIST SUPERLONG ARTIST SUPERLONG ARTIST SUPERLONG ARTIST</td>
</tr>
</tbody>
</table>
【问题讨论】:
标签: html-table responsive-design css-tables