响应式网站在移动设备上缩小到全宽

law*_*tog 134 user-interface responsive-design twitter-bootstrap twitter-bootstrap-3 bootstrap-4

我正在测试Bootstrap响应性导航栏,我有一个演示网站.当我在桌面上调整浏览器大小时,一切正常,包括导航栏,它成为可折叠菜单,顶部有一个小图标,我可以单击该按钮查看更多菜单按钮.

但是当我从移动浏览器尝试它时(我在Android上尝试使用chrome和互联网浏览器),我没有看到响应式设计.我只能看到像网站这样的非常小的桌面版本.

谁能指出我做错了什么?

Zim*_*Zim 370

将其添加到您的HTML头...

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
Run Code Online (Sandbox Code Playgroud)

这告诉较小的设备浏览器如何缩放页面.你可以在这里阅读更多相关信息:https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html

  • @Skelly - 我看到的其他答案省略了“最大规模”,并使用“1.0”而不是“1”。你知道这些事情会产生影响吗? (2认同)

Tom*_*Tom 17

正如这里建议的那样http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-dont-forget-the-viewport-meta-tag/

<meta name="viewport" content="initial-scale=1">
Run Code Online (Sandbox Code Playgroud)

将是一个更好的选择,因为它可以实现从纵向到横向,并带来更加愉悦的用户体验,因为/ height会自然采用,因为可能会自动缩放.