【问题标题】:Media query does not work in VueJS style tag媒体查询在 VueJS 样式标签中不起作用
【发布时间】:2020-05-11 20:12:09
【问题描述】:

我正在尝试在 VueJS 组件的样式标签中使用 @media。 @media 中的样式始终有效,而不是使用宽度规则。

<template>
    <header class="header"></header>
</template>

<script>
    export default {

    }
</script>

<style scoped>
    .header {
        height: 2000px;
        background-color: black;
    }

    @media only screen and (min-width: 576px) {
        .header {
            height: 2000px;
            background-color: white;
        }
    }
</style>

但是它在原始 .html 文件中按预期工作。

【问题讨论】:

    标签: css vue.js media-queries


    【解决方案1】:

    问题解决了。它与 vue.js 或任何东西无关。这是因为 index.html 文件中缺少元标记。

    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    

    【讨论】:

      猜你喜欢
      • 2013-02-03
      • 2022-01-04
      • 2023-03-10
      • 2012-09-10
      • 1970-01-01
      • 1970-01-01
      • 2014-02-21
      相关资源
      最近更新 更多