【发布时间】:2021-05-23 09:46:21
【问题描述】:
我想构建一个看起来像窗口应用程序的页面。有一个问题,当我放大页面时,它会在主页上显示一个滚动条。 我将主页(父)的参数设置如下。 宽度:100vw, 高度:100vh
我应该怎么做才能滚动浏览主页内的组件(子组件)而不是主页(父组件)。 我把我的代码的 css 部分放在下面。
主页(父)的第一个 css 代码。我使用 Material-ui 进行样式设置。 root 是主页的类名。 header、breadCrumb 和 content 是我的子组件的 className。
const useStyles = makeStyles({
root: {
width:'100vw',
height: '100vh',
},
header: {
height: '10%',
},
breadCrumb: {
height: '10%',
},
content: {
height: '80%',
}
});
内容组件也有自己的子项(侧边栏和内容),我将它们的 css 属性放在下面。
const useStyles = makeStyles({
root: {
border: '1px solid blue',
display: 'flex',
width:'auto',
height: 'auto',
},
sidebar: {
backgroundColor: 'orange',
width: '20%',
height: 'auto',
border: '1px solid red',
overflow: 'scroll'
},
content: {
height: 'auto',
width: '80%',
}
});
有什么我忘记设置的吗?如果可以的话,请指导我解决这个问题。
【问题讨论】:
标签: css reactjs flexbox material-ui scrollbar