2 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊
您可以嵌套 flexbox 并定義父 flexbox 的高度。
這是我的例子。
mapContainerStyle
const mapStyles = {
width: '100%',
- height: '100vh',
+ height: "100%",
};
APP COMPONENT
return(
<div
style={{ height: "100vh", display: "flex", "flex-direction": "column" }}
>
<div>
<MapNavbar />
</div>
<div style={{ "flex-grow": "1" }}>
<WrappedMap
// your props...
/>
</div>
</div>
)
使用 Material UI Box 更簡(jiǎn)單。
APP COMPONENT
return(
<Box display="flex" flexDirection="column" style={{ height: "100vh" }}>
<Box>
<MapNavbar />
</Box>
<Box flexGrow={1}>
<WrappedMap
// your props...
/>
</Box>
</Box>
)
添加回答
舉報(bào)