Vittore Gravano
Vittore Gravano

Reputation: 766

Window width in JavaScript

I have some mystic troubles with $(window).width().

I open my site in Chrome Device Toolbar with 320xXXX window size. Then, I run in Google Chrome JavaScript console $(window).width() and it says 980. And that's why none of my @media in css not working. Is there is any explanation for that?

By the way, when I resize Chrome window, it magicaly start to see correct window width.

Upvotes: 0

Views: 177

Answers (1)

Đào Minh Hạt
Đào Minh Hạt

Reputation: 2930

As OP's comment, here is the answer.

You will need to add viewport tag to archive @media css

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

Upvotes: 1

Related Questions