聚合物芯集管面板高度问题

polymer core-header-panel height issue

为什么这两个片段不同? 第一个片段按预期工作 第二个只是将 body 标签内容的副本放入名为 my-header 的自定义元素中,并将 my-header 插入到 body 标签中

第二个不符合使用全出血垂直布局的 body 标签的高度。

<!doctype html>
<html>

<head>
    <link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
    <link rel="import" href="http://www.polymer-project.org/components/core-header-panel/core-header-panel.html">
    <link rel="import" href="http://www.polymer-project.org/components/core-toolbar/core-toolbar.html">
</head>

<body fullbleed layout vertical>

<core-header-panel flex>
    <core-toolbar>
        <div>Hello World!</div>
    </core-toolbar>
    <div class="content">Content goes here...</div>
</core-header-panel>

</body>

</html>

<!doctype html>
<html>

<head>
    <link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
    <link rel="import" href="http://www.polymer-project.org/components/core-header-panel/core-header-panel.html">
    <link rel="import" href="http://www.polymer-project.org/components/core-toolbar/core-toolbar.html">
    <polymer-element name="my-header" attributes="">
        <template>
            <style>
            </style>
            <core-header-panel flex>
                <core-toolbar>
                    <div>Hello World!</div>
                </core-toolbar>
                <div class="content">Content goes here...</div>
            </core-header-panel>
        </template>
        <script>
            (function () {

                Polymer({
                    // define element prototype here
                });

            })();
        </script>
    </polymer-element>
</head>
<body fullbleed layout vertical>
<my-header></my-header>

</body>

</html>

您只需将高度添加到您的元素,然后 core-header-panel

  <style>
    :host, core-header-panel {
      height: 100%;
    }
  </style>

<!doctype html>
<html>

<head>
  <link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
  <link rel="import" href="http://www.polymer-project.org/components/core-header-panel/core-header-panel.html">
  <link rel="import" href="http://www.polymer-project.org/components/core-toolbar/core-toolbar.html">
  <polymer-element name="my-header">

    <template>
      <style>
        :host,
        core-header-panel {
          height: 100%;
        }
      </style>

      <core-header-panel flex>
        <core-toolbar>
          <div>Hello World!</div>
        </core-toolbar>
        <div class="content">Content goes here...</div>
      </core-header-panel>

    </template>

    <script>
      (function() {

        Polymer({
          // define element prototype here
        });

      })();
    </script>
  </polymer-element>
</head>

<body fullbleed layout vertical>

  <my-header></my-header>

</body>

</html>