question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@media does not work in .vue file's style area

See original GitHub issue

Version

2.6.10

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

Create a new component in .vue file

<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>

What is expected?

Media query detects different resolutions and apply styling

What is actually happening?

Media query does not work and the styling with line priority applies.


If I don’t use VueJS it works just fine. I tried with raw html css it is fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
MansurAliKoroglucommented, Jan 28, 2020

Problem solved. There was a missing meta tag on index.html

<meta name="viewport" content="width=device-width,initial-scale=1.0">
0reactions
tsegacommented, Jan 28, 2020

If you can share your codebase maybe I can help, but better to take this on to Discord; https://discordapp.com/invite/HBherRA

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media query does not work in VueJS style tag - Stack Overflow
Problem solved. It is not related with vue.js or anything. It is because of a missing meta tag in index.html file.
Read more >
Media queries won't work without !important - Vue Forum
Try inspecting the relevant element in the browser developer tools to see what CSS rules are being applied and what selectors are used....
Read more >
Styling Vue components with CSS - Learn web development
Our work is done on the styling of our sample app. In the next article we'll ... Global styles in Single File Components...
Read more >
How To Implement Responsive Design in Vue.js with vue-mq
The trick is to use a breakpoint name as a computed class on the element you want to style. Here is an example...
Read more >
Styling a Vue.js application using CSS - LogRocket Blog
To do so efficiently, we will use global styling, rather than styling them in a scoped or external file (although this would work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found