MDL导航栏图标问题

时间:2017-09-29 21:31:50

标签: html css material-design-lite

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

我打开了链接

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

1 个答案:

答案 0 :(得分:3)

Codepen代码与您的代码之间的唯一区别是缺少<!DOCTYPE html>。起初,你可能想知道,那又怎样?确定浏览器可以处理它,对吗?事实是,省略<!DOCTYPE html>会强制您的浏览器在Quirks Mode 中呈现您的网页。

那么,怪癖模式会出现什么问题?怪癖模式中可能会出现很多问题。我怀疑flexbox在你的情况下不能正常工作(我会调查它并稍后再回来)。

一些有用的信息: