Fill page with iron-pages element

最后都变了- 提交于 2019-12-11 01:37:38

问题


I'm trying to fill the entire page with an iron-pages element. With the following code I trying to create a page that looks like the following:

 -------------------------------------
| Top                                 |
 -------------------------------------
| Bottom                              |
|                                     |
|                                     |     
|                                     |
|                                     |
|                                     |       
 -------------------------------------

Code:

<html>
<head>
    <script src="bower_components/webcomponentsjs/webcomponents.js"></script>

    <link rel="import" href="bower_components/polymer/polymer.html">
    <link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html">
    <link rel="import" href="bower_components/iron-pages/iron-pages.html">

    <style is="custom-style">
        html,body {
            margin: 0;
            padding: 0;
            height: 100%;
            background-color: yellow;
        }
        div {
            border: 2px solid grey;
            background-color: white;
            margin: 2px;
        }
        p {
            margin: 5px;
        }
        .outer {
            width: 100%;
            height: 100%;
            @apply(--layout-vertical);
            @apply(--layout-flex);
        }
        .inner {
            @apply(--layout-flex);
        }
    </style>
</head>
<body>
    <div class="outer">
        <div><p>Top</p></div>
        <iron-pages selected="0" class="inner">
            <div><p>Bottom</p></div>
        </iron-pages>
    </div>
</body>
</html>

However, the bottom section is not expanding to fill the available space.

If I remove the iron-pages element and add the inner style to the bottom div, I get the desired result.


回答1:


Solved the issue. The iron-pages element needs to flex to take the available space (as it was) and then the content also need to flex to fill the full area.

<html>
<head>
    <script src="bower_components/webcomponentsjs/webcomponents.js"></script>

    <link rel="import" href="bower_components/polymer/polymer.html">
    <link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html">
    <link rel="import" href="bower_components/iron-pages/iron-pages.html">

    <style is="custom-style">
        html,body {
            margin: 0;
            padding: 0;
            height: 100%;
            background-color: yellow;
        }
        div {
            border: 2px solid grey;
            background-color: white;
            margin: 2px;
        }
        p {
            margin: 5px;
        }
        .outer {
            width: 100%;
            height: 100%;
            @apply(--layout-vertical);
            @apply(--layout-flex);
        }
        .inner {
            @apply(--layout-flex);
            @apply(--layout-vertical);
        }
        .content {
            @apply(--layout-flex);
        }
    </style>
</head>
<body>
    <div class="outer">
      <div><p>Top</p></div>
      <iron-pages selected="0" class="inner">
          <div class="content">
              <p>Bottom</p>
          </div>
      </iron-pages>
    </div>
</body>
</html>


来源:https://stackoverflow.com/questions/33598105/fill-page-with-iron-pages-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!