我正在创建一个新的页面,可以由用户用CTRL + P打印。在这个页面中,我有一些图表(带有hightchart),但当我有许多图表时,它正在剪切图表。因此,我尝试在名为"testVal“的div上使用break-inside,但仍然不起作用。
我试图打印一页,但其中一个div被剪切了:

我的代码:
{map(blocks, ({ kpi, ...block }, blockIndex) => {
const blocType = get(block, 'type', type);
const { getW, splitIntoChunk } = blockParams[blocType];
const kpiRows = splitIntoChunk(kpi);
return (
<TestVal>
<Grid item xs={12} key={`${key}_blocks_${blockIndex}`}>
<Block container>
{block.title ? (
<BlockTitle data-testid={`section_${sectionIndex}_block_${blockIndex}_title`}>
<Typography variant="h5">{block.title}</Typography>
</BlockTitle>
) : null}
<Grid item sm={12}>
{map(kpiRows, (row, rowIndex) => (
<KPIRow key={`section_${sectionIndex}_row_${rowIndex}`} item xs={12} margin={2} style={{ marginBottom: spacings.regular_1 }}>
<Grid container spacing={2} alignItems="stretch" data-testid={`section_${sectionIndex}_block_${blockIndex}_row_${rowIndex}`}>
{map(row, (kpiData, i) => {
const w = getW(row.length, kpi.length);
return (
<KPIWrapper key={`${key}_row_${rowIndex}_kpi_${i}`} item xs={w}>
<KPIContent><KpiBase data={kpiData} w={w} /></KPIContent>
</KPIWrapper>
);
})}
</Grid>
</KPIRow>
))}
</Grid>
</Block>
</Grid>
</TestVal>
);
})}我用我的风格做了这样的突破:
export const TestVal = styled.div`
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
background-color:red;
`;你有什么想法吗?可能是因为我使用的是材料UI :/?
发布于 2020-01-25 02:20:22
好了,我终于找到了。我在parent div上有display:flex。如果我把它们去掉,它就像护身符一样起作用。因此看起来像display flex break这个css选项
https://stackoverflow.com/questions/59899783
复制相似问题