html - 如何阻止我的 HTML 水平表(使用 mini.css)内容消失在标题后面
问题描述
我正在使用 mini.css 设置简单网页的样式以显示应用程序的输出。我使用以下 HTML 创建了一个水平表,但是当我调整窗口大小而不是右侧列右侧的巨大空白变小时,文本向左移动并开始消失在标题后面。最终,响应式设计启动并完全改变了表格布局,但在表格难以辨认之前。
理解我的意思的最简单方法是尝试这个 codepen: https ://codepen.io/sonotley/pen/RwKzJzG
<table class="horizontal">
<thead>
<tr>
<th>Number of pings</th>
<th>Max response time</th>
<th>Min response time</th>
<th>Mean response time</th>
</tr>
</thead>
<tbody>
<tr>
<td>366544</td>
<td>2547</td>
<td>78</td>
<td>178</td>
</tr>
</tbody>
</table>
我尝试将表格包装在各种 div 类(容器、卡片、行、列等)中,但它们都没有阻止这种效果。事实上,如果您尝试将表格放在“大卡片”类的 div 中,表格看起来很棒,但文本完全隐藏了!我还尝试向 td 标签添加样式以右对齐文本,但我真的不希望它右对齐,无论如何它都不起作用。我可以在我的页面中添加什么 CSS 来防止这种奇怪的行为?
解决方案
我用不同尺寸的屏幕解决了这个问题padding-left
。
table th {
text-align: left !important;
}
@media screen and (min-width: 840px) and (max-width: 900px) {
table td {
padding-left: 30px !important;
}
}
@media screen and (min-width: 750px) and (max-width: 840px) {
table td {
padding-left: 50px !important;
}
}
<link rel="stylesheet" href="https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css">
<table class="horizontal">
<thead>
<tr>
<th>Number of pings</th>
<th>Max response time</th>
<th>Min response time</th>
<th>Mean response time</th>
</tr>
</thead>
<tbody>
<tr>
<td>366544</td>
<td>2547</td>
<td>78</td>
<td>178</td>
</tr>
</tbody>
</table>
推荐阅读
- wordpress - 无法在 WordPress 中运行 cron 作业
- android-livedata - 如何使用 liveData 协程块
- ionic-framework - Ionic 应用程序在启动画面后卡在白屏上
- scala - 比较 Seq 和 Array 的不同行为
- javascript - 如何在 jquery 数据表中显示没有(键值)对的数据?
- c# - 为什么我的应用程序在使用 webClient 上传图片后变慢了?
- c++ - 如何设置获取类的私有成员:寻找更好的方法
- loadrunner - 需要一种通过truclient关闭浏览器实例的方法
- node.js - “基础”命令在 nodeJS 文件夹之外是未知的
- android - 如何在kotlin中使用一个简单的数据类