You need to enable JavaScript to run this app. 如何移除Media Queries实现表格在所有设备保持桌面端固定布局
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Media Queries实现表格在所有设备保持桌面端固定布局

解决方案

你现有代码默认内置了移动端响应式适配规则,要实现全设备统一展示桌面端布局,按以下步骤修改即可:


1. 调整HTML头部的viewport配置

viewport标签控制移动端页面的缩放和宽度适配,你需要在HTML的<head>标签中添加如下配置,固定页面宽度为桌面端表格的960px宽度,禁止自动缩放:

<meta name="viewport" content="width=960, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

2. 删除CSS中的移动端响应式逻辑

你提供的CSS中有3个针对宽度≤768px设备的媒体查询块,这些就是触发移动端布局变换的代码,直接删除所有这些块即可。删除后的完整CSS如下:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

body,
html {
  height: 100%;
  font-family: sans-serif
}

a {
  margin: 0;
  transition: all .4s;
  -webkit-transition: all .4s;
  -o-transition: all .4s;
  -moz-transition: all .4s
}

a:focus {
  outline: 0 !important
}

a:hover {
  text-decoration: none
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0
}

p {
  margin: 0
}

li,
ul {
  margin: 0;
  list-style-type: none
}

input {
  display: block;
  outline: 0;
  border: none !important
}

textarea {
  display: block;
  outline: 0
}

input:focus,
textarea:focus {
  border-color: transparent !important
}

button {
  outline: 0 !important;
  border: none;
  background: 0 0
}

button:hover {
  cursor: pointer
}

iframe {
  border: none !important
}

.limiter {
  width: 100%;
  min-width: 960px;
  margin: 0 auto
}

.container-table100 {
  width: 100%;
  min-height: 100vh;
  background: #c4d3f6;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 33px 30px
}

.wrap-table100 {
  width: 960px;
  border-radius: 10px;
  overflow: hidden
}

.table {
  width: 100%;
  display: table;
  margin: 0
}

.row {
  display: table-row;
  background: #fff
}

.row.header {
  color: #fff;
  background: #6c7ae0
}

.cell {
  display: table-cell
}

.row .cell {
  font-family: Poppins, sans-serif !important;
  font-weight: 400 !important;
  font-size: 15px;
  color: #666;
  line-height: 1.2;
  font-weight: unset !important;
  padding-top: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f2f2f2
}

.row.header .cell {
  font-family: Poppins, sans-serif !important;
  font-weight: 400 !important;
  font-size: 18px;
  color: #fff;
  line-height: 1.2;
  font-weight: unset !important;
  padding-top: 19px;
  padding-bottom: 19px
}

.row .cell:nth-child(1) {
  width: 240px;
  padding-left: 40px
}

.row .cell:nth-child(2) {
  width: 240px;
  padding-left: 20px
}

.row .cell:nth-child(3) {
  width: 240px;
  padding-left: 20px
}

.row .cell:nth-child(4) {
  width: 240px;
  padding-left: 0
}

.row,
.table {
  width: 100% !important
}

.row:hover {
  background-color: #ececff;
  cursor: pointer
}

注:已同步在.limiter类中添加了min-width: 960px属性,保证小屏幕下页面不会被压缩变形,可横向滑动查看完整表格


内容的提问来源于stack exchange,提问作者Aditya Vaste

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.12 03:27:04