我正在创建一个文档上载系统,并且希望所有已上载的文档都具有一行,最后一行是“添加另一个文档”行。当前,具有行的列表容器不会扩展,而只会减小列表中项目的高度。相反,我试图让父级高度扩展为包括列表中的所有项目。任何帮助表示赞赏!
import React, { Component } from 'react';
export class Upload extends Component {
render() {
return (
<div style={{'height': '100vh', 'display': 'flex', 'justifyContent': 'center', alignItems: 'center'}}>
<div style={{'flex': 0.8, maxWidth: 800, flexGrow: 1, 'borderRadius': 10, 'boxShadow': '0px 0px 10px #82828240', 'paddingLeft': 50, 'paddingRight': 50, 'paddingTop': 100, 'paddingBottom': 100, display: 'flex', flexDirection: 'column'}}>
<div>
<h2>Document upload</h2>
<p>Some subtitle placeholder</p>
</div>
<hr />
<div style={{'display': 'flex','flexDirection': 'column', backgroundColor: 'red'}}>
<div style={{flex: 1, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
<div style={{flex: 1, flexShrink: 0, backgroundColor: 'blue', marginTop: 20, marginBottom: 20}} />
{/* <button type='button' style={{'flex': 1, flexShrink: 0, 'borderStyle': 'dashed'}} onClick={() => this.input.click()}/>
<input id='file-upload' type="file" style={{display: 'none'}} ref={(input) => this.input = input}/> */}
</div>
</div>
</div>
);
}
}
答案 0 :(得分:1)
删除height: 80%
,然后将li
更改为div
。