Material Design Lite响应式CSS无法在Mobile / Tablets或Chrome DevTools模拟器

时间:2015-10-09 17:33:53

标签: html css responsive-design material-design-lite

在尝试使用Google Material Design Lite的响应功能时,此代码会在调整浏览器窗口大小时按预期隐藏消息,但当我在Chrome DevTools设备模拟器或实际设备上查看我的页面时,它只会显示“桌面”版本。如何修复HTML?

<html>
  <head>
     <link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.1/material.indigo-pink.min.css">
  </head>
  <body>
       <div class="mdl-cell--hide-phone mdl-cell--hide-tablet">
          You are on a desktop
       </div>
       <div class="mdl-cell--hide-desktop mdl-cell--hide-tablet">
          You are on a phone
       </div>
       <div class="mdl-cell--hide-desktop mdl-cell--hide-phone">
          You are on a tablet
       </div>
  </body>
</html>

1 个答案:

答案 0 :(得分:8)

要修复MDL而不是针对不同设备进行缩放,请在HTML <head>中添加此行:

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