html - 即使使用 <meta> 标记,媒体查询也无法正常工作

标签 html css media-queries

我正在为我的音乐制作一个简单的网站(安全隧道)http://79a6b00f.ngrok.io使用媒体查询和所有内容,并在 index.html 的 header 中使用元标记 ( <meta name="viewport" content="width=device-width, initial-scale=1"> )。

我让人在手机上进行了测试,结果网站缩小了,而不是保持比例并显示汉堡菜单。这是我的查询代码:

@media all and (max-width: 2600px) {
    .w-ctrl {
        width: 950px;
        margin: auto;
    }
}

@media all and (max-width: 966px) {
    .w-ctrl {
        width: 100%;
        margin: auto;
    }
    .sub-header {
        width: 100%;
        background: #37474F;
        height: 500px
    }
    .lnd-con .pic {
        height: 500px;
        background-attachment: scroll;
    }
    .lnd-con .label-con {
        top: -350px;
        text-align: center;
    }
    .label-con .title {
        font-size: 25px;
    }
    .label-con .subtitle {
        font-size: 25px;
    }
}

@media all and (max-width: 636px) {
    .w-ctrl {
        width: 100%;
        margin: auto;
    }
    .nav-con-big {
        display: none;
    }
    .nav-con-small {
        display: block;
    }
    .lnd-con .pic {
        height: 300px;
    }
    .title-con {
        display: none;
    }
    .lnd-con {
        margin-top: 0px;
    }
    .lnd-con .label-con {
        position: static;
        text-align: left;
        background: transparent;
        padding-top: 5px;
        padding-bottom: 8px;
        letter-spacing: 0px;
    }
    .label-con .title {
        font-size: 20px;
    }
    .label-con .subtitle {
        font-size: 18px;
    }
    .sub-header {
        width: 100%;
        height: 400px
    }
}

我无法将我的网站放入 js-fiddle,因此我创建了一个隧道。我希望没关系,据我所知,我没有违反任何规则。

最佳答案

我在你的 global.css 顶部看到这个声明:

@viewport {
  zoom: 1.0;
  width: extend-to-zoom;
}

取出或者设置width: device-width;:

@viewport {
  width: device-width;
}

此外,对 css 设备适配的支持相当差( http://caniuse.com/#search=%40viewport ),可能与元标记实现存在某种冲突

关于html - 即使使用 &lt;meta&gt; 标记,媒体查询也无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31079974/

相关文章:

javascript - 识别文本区域内的 Open-Math (XML) 代码

html - 表格内容不应该用固定的表格列换行

应用于正文的 HTML5 全屏 API

javascript - 鼠标滚动时放大和缩小图像

ios - 根据 iOS 环境主题自动在浅色和深色之间更改 iOS 应用程序主题

ipad - 条件@import 和@media - CSS

html - img-responsive 不居中

html - 如果页面较短,则将 HTML 页脚保留在窗口底部

html - 如何在 bootstrap 4 中使子内容相对于父容器垂直居中

jquery - 修复 XL 屏幕上的 Bootstrap 4 多项目轮播