在试用 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>
最佳答案
要修复 MDL 不针对不同设备缩放的问题,请将此行添加到 HTML 的 <head>
中:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
关于html - Material Design Lite 响应式 CSS 不适用于移动设备/平板电脑或 Chrome DevTools 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33044102/