html - CSS 溢出的响应表问题

标签 html css responsive-design

我上次找到了一个解决方案,我需要一个表格来通过移动设备进行响应。解决方案是在 table 周围放置一个 div 并使用溢出滚动。但是,我需要更新其中没有 div 类“tablewrapper”的模板负载,那么有没有办法只在表格或 tbody 上设置溢出滚动条?

HTML 表格代码

<h3 class="showOnMobile">Swipe right or rotate your device to see full table</h3>
<div class="tablewrapper">
<table>
<tbody>
</tbody>
<thead>
<tr>
<th scope="col">Code</th>
<th scope="col">Colour</th>
<th scope="col">Capacity Litre</th>
<th scope="col">Height</th>
<th scope="col">Diameter</th>
<th scope="col">Weight</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Code">123</td>
<td data-label="Colour">Stainless Steel</td>
<td data-label="Capacity Litre">45Ltr</td>
<td data-label="Height">0.65m</td>
<td data-label="Diameter">0.35m</td>
<td data-label="Weight">3.1kg</td>
</tr>
</tbody>
</table>
</div>

tablewrapper 的 CSS

.tablewrapper { 
    max-width:100vw;
    overflow-y:scroll;
}
@media only screen and (min-width: 600px) {
    h3.showOnMobile { 
        display:none;
    }
}

最佳答案

如果我是对的,你想替换 div class= tablewrapper 并想直接在表格上应用样式对吧??? 我删除了 div,而是按照 table 标记 itslef 的样式。

table { 
    max-width:100vw;
    overflow-y:scroll;
    display: block;
}

效果一样。请让我知道您的问题是否相同。

关于html - CSS 溢出的响应表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42980207/

相关文章:

javascript - 如何使 Three.js FOV 响应高度和宽度?

javascript - 阻止视频在手机后台加载

javascript - 如何制作真正的响应式图像 slider ?

html - 如何使图像和文本彼此对齐

css - 508 - 同一图标的替代文本

css - 如何在 JavaFX 中的按钮上使用 CSS(见下图)实现 "shine"效果?

html - 如何将对 Angular 线 block 添加到响应式设计中?

html - 我怎样才能使从左侧滑入的 flexbox 过渡到页面居中?

javascript - 如何开始 phonegap 开发?

html - 工具提示悬停时的过渡在 IE 上不起作用,在谷歌浏览器中运行良好