网址为http://action.news 固定宽度表中有3列)
(我删除了按需加载的脚本)以简化操作。 谢谢你
我做了什么: 在下面添加了此代码
https://gist.github.com/hkirsman/3002480
根据Google说明添加此内容
<meta name=viewport content="width=device-width, initial-scale=1">
我已阅读HTML table with auto-fit for some columns, fixed width for others
但仍然无法让页面移动友好,顶部似乎重新调整
答案 0 :(得分:0)
我在Codepen上找到了这个示例,因此您可以尝试并根据需要进行调整:
这是一些代码
HTML:
<table class="js-table participants-table">
<caption>
<p>Responsive Table</p>
</caption>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Picture</th>
</tr>
</thead>
<tbody>
<!--filled from javascript-->
</tbody>
</table>
CSS:
HTML {
font-size: 100%;
line-height: 1.5;
font-family: 'Raleway', sans-serif;
}
BODY {
margin: 0;
}
*, *:before, *:after {
box-sizing: border-box;
}
IMG {
max-width: 100%;
}
/*Style For Table*/
.participants-table {
table-layout: fixed;
border-collapse: collapse;
margin: 0 auto;
width: 90%;
}
.participants-table TD,
.participants-table TH {
border: 1px solid #b4adad;
}
.participants-table IMG {
width: 150px;
}
.participants-table THEAD {
display: none;
}
.participants-table TD {
display: block;
position: relative;
overflow-x: hidden;
text-overflow: ellipsis;
}
@media only screen and (min-width: 450px) {
.participants-table {
width: auto;
}
.participants-table TD,
.participants-table TH {
padding: .2em 1em;
}
.participants-table THEAD {
display: table-header-group;
}
.participants-table TD {
display: table-cell;
position: static;
}
.participants-table TD:before {
display: none;
}
}