简体   繁体   中英

@media (max-width: 640px) not working for mobile

This codepen link: https://codepen.io/gianlucaas/pen/bGrmQVO hosts my code for one of my pages for a new website.

the problem is, when I go and test it on mobile (you can try it too, on the codepen link), it looks perfect. you can see the rolex goes to the top right corner (the image) and it looks proper. BUT, when i go to my live link, which is (won't show now for privacy purposes). please see answer that solved issue below...

(ON MY IPHONE), it looks like the desktop application, but it is supposed to look like the phone version! I cannot figure out why for the life of me. Does anyone have any suggestions as to what I could be doing wrong?

In your codepen you've got the max-width at 640px:

@media (max-width: 640px) {

In your live app it's 440px:

@media (max-width: 440px) {

您需要在页眉中定义视口,codepen 补充说。

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

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