MDL 导航栏图标问题

MDL nav bar icon issue

来自getmdl.io/components/index.html#layout-section

我打开link到

https://codepen.io/anon/pen/MEoBqG

当我保存 html 代码并在本地少数浏览器中打开它时。我看到菜单按钮错位了。

<html>
  <head>
    <!-- Material Design Lite -->
    <script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
    <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
    <!-- Material Design icon font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  </head>
  <body>
    <!-- Simple header with scrollable tabs. -->
    <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>
        </div>
        <!-- Tabs -->
        <div class="mdl-layout__tab-bar mdl-js-ripple-effect">
          <a href="#scroll-tab-1" class="mdl-layout__tab is-active">Tab 1</a>
          <a href="#scroll-tab-2" class="mdl-layout__tab">Tab 2</a>
          <a href="#scroll-tab-3" class="mdl-layout__tab">Tab 3</a>
          <a href="#scroll-tab-4" class="mdl-layout__tab">Tab 4</a>
          <a href="#scroll-tab-5" class="mdl-layout__tab">Tab 5</a>
          <a href="#scroll-tab-6" class="mdl-layout__tab">Tab 6</a>
        </div>
      </header>
      <div class="mdl-layout__drawer">
        <span class="mdl-layout-title">Title</span>
      </div>
      <main class="mdl-layout__content">
        <section class="mdl-layout__tab-panel is-active" id="scroll-tab-1">
          <div class="page-content"><!-- Your content goes here --></div>
        </section>
        <section class="mdl-layout__tab-panel" id="scroll-tab-2">
          <div class="page-content"><!-- Your content goes here --></div>
        </section>
        <section class="mdl-layout__tab-panel" id="scroll-tab-3">
          <div class="page-content"><!-- Your content goes here --></div>
        </section>
        <section class="mdl-layout__tab-panel" id="scroll-tab-4">
          <div class="page-content"><!-- Your content goes here --></div>
        </section>
        <section class="mdl-layout__tab-panel" id="scroll-tab-5">
          <div class="page-content"><!-- Your content goes here --></div>
        </section>
        <section class="mdl-layout__tab-panel" id="scroll-tab-6">
          <div class="page-content"><!-- Your content goes here --></div>
        </section>
      </main>
    </div>
  </body>
</html>

如何解决菜单图标错位的问题?为什么它在 codepen 上看起来不错,但在本地却不好看?

screenshot with mispositioned icon

Codepen 代码和您的代码之间的唯一区别是缺少 <!DOCTYPE html>。一开始,你可能会想,那又怎样?确定浏览器可以处理它,对吗?事实是,省略 <!DOCTYPE html> 会强制您的浏览器在 Quirks Mode.

中呈现您的页面

那么,怪癖模式会出现什么问题?在怪癖模式下,很多事情都可能出错。我怀疑 flexbox 在您的案例中没有按预期工作(我会调查一下,稍后再回来)。

一些有用的信息: