【发布时间】:2015-07-26 13:32:21
【问题描述】:
我现在正在调试一个非常奇怪的错误。
我正在试用 Material Design Lite:http://www.getmdl.io/components/index.html#layout-section
但每当我从他们的官方 CodePen (http://codepen.io/anon/pen/WvaKjK) 复制/粘贴“固定标题”示例时,它在我的浏览器中看起来会有所不同:
这是使用的整个 HTML:
<html>
<head>
<!-- Material Design Lite -->
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.1/material.min.js"></script>
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.1/material.indigo-pink.min.css">
<!-- Material Design icon font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<!-- Always shows a header, even in smaller screens. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Title</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation. We hide it in small screens. -->
<nav class="mdl-navigation mdl-layout--large-screen-only">
<a class="mdl-navigation__link" href="">Link</a>
</nav>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">Title</span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">Link</a>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content">
<!-- Your content goes here -->
</div>
</main>
</div>
</body>
</html>
如果您比较两个标题,您会发现左上角的图标不在位。那么问题就来了。
因为我在我的机器上使用 same 代码,这使得图标看起来不合适,但每当我从浏览器中 复制/粘贴 代码时,f.e. cmd+U 到 jsfiddle 或者 codepen,我把 Icon 放对了。
看这里:
http://codepen.io/anon/pen/LVgBzZ
这不是浏览器问题,因为同样的问题也出现在 Firefox、Chrome、Chrome Canary 和 Android Chrome 中。我这里上传了同样的HTML,显示错误:
http://temp.leavingblue.com/5.html
我在本地机器上的 windows (wamp) 和 linux 虚拟机 (homestead) 上运行代码。
TL;DR:
相同的 HTML 在官方 getmdl.io 站点、codepen、jsfiddle 中看起来不错,但是当我在自己的 HTML 文件中重新创建它时看起来很奇怪。
如何重现错误
前往
- http://temp.leavingblue.com/5.html,
- Cmd + U
- 全部复制/粘贴到 Codepen.io
- 查看差异
谁能重现错误?还有人解释这种行为吗?
【问题讨论】:
标签: javascript html css material-design-lite