html - 媒体查询不适用于移动纵向模式

标签 html css

将以下内容应用于媒体查询时,它不适用于移动纵向模式。它在移动横向模式和桌面上运行良好。 这是我的代码

.post-table-new {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  display: table;
  color: #000
}

.post-table-new tr,
.post-table-new th,
.post-table-new td {
  border: 1.5px solid #000
}

.post-table-new {
  background-color: #fff
}

.post-table-new td,
.post-table-new th {
  display: table-cell;
  text-align: center;
  vertical-align: top
}

.post-table-new th {
  background-color: #fe074e;
  color: #fff
}

@media only screen and (max-width: 600px) {
  td.hide-col {
    display: none;
    width: 0;
    height: 0;
    opacity: 0;
    visibility: collapse;
  }
  th.hide-col {
    display: none;
    width: 0;
    height: 0;
    opacity: 0;
    visibility: collapse;
  }
}
<meta charset=UTF-8>
<meta name=viewport id=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

<table class="post-table-new">
  <tbody>
    <tr>
      <th>Heading</th>
      <th>Heding 2</th>
      <th class="hide-col">Heding 2</th>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td class="hide-col">3</td>
    </tr>
    <tr>
      <td>4</td>
      <td>5</td>
      <td class="hide-col">6</td>
    </tr>
  </tbody>
</table>

这里我想隐藏表格的一列。当减小浏览器的大小时,它在桌面上工作正常。它在移动横向模式下也工作正常,但在移动纵向模式下不工作。

最佳答案

// add orientation media query, landscape or portrait

@media screen and (max-width: 600px) , screen and (orientation:landscape)

关于html - 媒体查询不适用于移动纵向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56659461/

相关文章:

javascript - 为什么我不能在 Django Web 应用程序中使用客户端摄像头拍摄图像快照?

html - 隐藏html水平但不垂直滚动条

jquery - 如何停止这个 jquery 选取框在鼠标悬停时滚动

jQuery 这不选择单个元素

javascript - 向文本溢出 : ellipsis 的元素添加标题属性

html - 具有不同大小元素的网格布局

javascript - jQuery 事件触发多次

javascript - 如何避免在 javascript 中生成重复的 html 代码

jquery - 使用 Href Id 添加图像,使用 CSS

javascript - 如何选择最后一行文本的第一个单词? (<h1> - <h6>, <p> 元素)