简体   繁体   中英

CSS @media rule in pug?

Is it possible to apply @media rules on pug? I don't know how to adjust my pages' components when the screen size is changed.

I've tried

@media only screen and (max-width : 320px){
    body{
      background: #FF5D50;
    }
}

but nothing happens when I change the device on Chrome.

All CSS including @media rules should work in Pug templates, you just need to ensure proper indentation below style.

style.
    @media only screen and (max-width: 320px) {
        body {
            background: #FF5D50;
        }
    }

Media query works once headers are set properly in pug layout.

meta(content='width=device-width' initial-scale='1' shrink-to-fit='no' name='viewport')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM