React DatePicker 日历显示在 table 头像后面

React DatePicker calendar showing behind table head

我在我的项目中使用了 react datePicker 和 fixed-data-table-2。当我打开日历时,它显示在 table 脑袋后面。这是 CSS 文件的代码:

.ui-datepicker {
   z-index: 9999 !important;
}
.table{
   z-index: -1000  !important;
}

这里是 DatePicker 的 React 代码:

 <div className='ui-datepicker'>
           <DatePicker
                 selected={this.state.startDate}
                 selectsStart
                 startDate={this.state.startDate}
                 endDate={this.state.endDate}
                 onChange={this.onFilterStart}
            />
</div>

这是 Table 的快捷方式代码:

<div className='table'>
     <Table
            rowHeight={50}
            rowsCount={tableData.getSize()}
            width={1000}
            maxHeight={1800}
            height={700}
            groupHeaderHeight={30}
            headerHeight={50}
            onColumnResizeEndCallback={this.resizeEndCallback}
            isColumnResizing={false}
            >
            <ColumnGroup
                header={<Cell>Basic Info</Cell>}>
                <Column columnKey='menuTranslation'
                        header={ <SortHeaderCell
                                languageChosen={this.state.languageChosen}
                                onSortChange={this.sortChange}
                                sortDir={colSortDirs.foodName}>Food 
              Name</SortHeaderCell>}
                        isResizable={true}
                        width={columnWidths.foodName}
                        cell={<MyTextCell data={tableData}  
              field='menuTranslation' col="menuTranslation"  />}
                />
<div>

这是问题的图片:

尝试在 .react-datepicker-popper 而不是日期选择器上设置 z-index。这是 react-date-picker 在它创建的弹出窗口中使用的类名。

.react-datepicker-popper {
    z-index: 9999 !important;
}

这是因为 Material-UI 纸张组件样式。 Paper 组件有一个 overflow: hidden 样式,删除它就完美了。

import Card from "@material-ui/core/Card";
...
<Card>
<DayPickerInput  id="servdate" name="servdate"  dateFormat="yyyy-mm-dd"/>
</Card>

在样式设置中.MuiCard-root{ overflow: visible!important; }

以防万一有人在这里结束并使用 Material-UI 卡片,我通过将 z-index: 0 !important 添加到 CardHeader 样式来解决它(我注意到它有 z-index: 3! important 默认使用 Chrome 开发工具)。

<CardHeader style={{zIndex: '0 !important'}}>
... 
</CardHeader>