gpt4 book ai didi

css - 带有 flexbox 的 polymer iron-list

转载 作者:行者123 更新时间:2023-11-28 15:45:00 24 4
gpt4 key购买 nike

我正在努力让 iron-listiron-flex-layoutpaper-card 一起玩。我希望 paper-card 在两个轴上 flex 扩展以覆盖页面(其边距作为保险杠),然后是 iron-list在其容器中垂直扩展,以显示我的 iron-list 及其所有“虚拟列表”魔法。

我哪里错了?

<script src="https://cdn.rawgit.com/Download/polymer-cdn/24b44b55/lib/webcomponentsjs/webcomponents-lite.min.js"></script>

<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/24b44b55/lib/paper-card/paper-card.html">
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/24b44b55/lib/paper-progress/paper-progress.html">
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/24b44b55/lib/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/24b44b55/lib/iron-list/iron-list.html">

<style is="custom-style" include="iron-flex iron-flex-alignment iron-positioning">
body {
margin: 0;
height: 100vh;
}

paper-card {
margin: 1em;
}

iron-list {
border-bottom: 1px solid #f00;
border-top: 1px solid #000;
}
</style>

<div class="vertical layout">
<template is="dom-bind" id="app">
<paper-card heading="My paper card" class="flex">
<div class="card-content layout vertical">
<div>[[listing.length]]</div>
<iron-list items="[[listing]]" class="flex">
<template>
<div class="layout horizontal">
<div>[[item.name]]</div>
<div>[[item.value]]</div>
</div>
</template>a
</iron-list>
</div>
</paper-card>
</template>
</div>

<script>
"use strict";

window.addEventListener('WebComponentsReady', e => {
app.listing = [];
for (var i = 0; i < 100; i++) {
app.push('listing', { name: i, value: i });
}
});
</script>

fiddle :https://jsfiddle.net/4czLkjfj/

最佳答案

您已将 body 元素设置为 height: 100vh

但是,这个高度不会被向下一级的 flex 容器继承。

一种解决方案是将display: flex 添加到body。这将创建一个 flex 容器,它会自动将 align-items: stretch 应用于子项。

body {
display: flex;
align-items: stretch; /* initial setting; can be omitted */
}

div.vertical.layout {
flex: 1; /* full width */
}

revised fiddle

另一种解决方案是简单地告诉 flex 容器继承父级的高度。

div.vertical.layout {
height: 100%;
}

revised fiddle


修改后的解决方案 基于评论中的反馈:demo

关于css - 带有 flexbox 的 polymer iron-list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42915715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com