【发布时间】:2018-08-09 15:44:40
【问题描述】:
我在它的正下方有一个 Appbar 和一个抽屉。在这两个组件下,我有 3 个带有引导程序的 divs,在每个 div 中,我有一组按钮。
问题是抽屉覆盖了应用栏,我似乎无法移动它。
这是我的代码:
<div className="App">
<AppBar position="static">
<Toolbar>
<IconButton color="inherit" aria-label="Menu">
<MenuIcon />
</IconButton>
<Typography variant="title" color="inherit" aria-label="Menu">
title
</Typography>
</Toolbar>
</AppBar>
<Drawer
variant="permanent"
style={{width: '100%', zIndex: '1400', position:'absolute'}}
>
<Button>1</Button>
<Button>2</Button>
<Divider />
<Button>1</Button>
<Button>2</Button>
</Drawer>
<br />
<div className="container-full">
<div className="row">
<div class="col-sm-6">
<GridList cellHeight={50} className={styles.gridList} cols={5}>
<Button style={{width: '150px', border: '1px solid'}} variant="raised" color="primary">
<div
style={{fontSize:'12px', display: 'flex', justifyContent: 'center', textAlign:'center'}}>
Mohnweckerl Wiener Gouda
</div>
</Button>
在第一个引导列之后,另一个 "col-sm-4" 紧随其后,然后是 "col-sm-2"。按钮位于GridList
这是一个视觉效果
抽屉应该从箭头相遇的地方开始。
有什么想法吗?
【问题讨论】:
-
尝试使抽屉的 z-index 小于应用栏的 z-index(您可能需要使用
!important才能使其生效)。您还需要在抽屉顶部添加 56 像素的填充。 -
如果我将
paddingTop:56或padding:56添加到抽屉中,它只会按下我的按钮。抽屉保持原样。 -
对,所以你还需要增加导航栏的 z-index,或者减少抽屉的 z-index。即,假设您想增加导航栏的 z-index。你可以使用
z-index: 24 !important; -
<AppBar position="absolute" style={{zIndex: 24}}>和抽屉内联style={{position:'relative', zIndex: 1, paddingTop:'56px !important'}}- 看起来像this -
编辑:对不起,我看错了你的评论。让我快速研究一下
标签: html css reactjs material-ui