简体   繁体   English

如何在 AccordionDetails 中设置 maxHeight 并使其可滚动?

[英]How do I set maxHeight inside AccordionDetails and make it scrollable?

I have 100's of data to show using Accordion (material-ui) inside a Box component, but not sure how to manipulate the built in styles to set the maxHeight.我在 Box 组件中使用 Accordion (material-ui) 显示了 100 条数据,但不确定如何操作内置样式来设置 maxHeight。 Is there a way that I can control the styles instead of showing all movies when the dropdown is clicked?有没有一种方法可以控制样式而不是在单击下拉菜单时显示所有电影?

Sandbox link 沙盒链接

Add this style in your css file and make height according your requirement, it works!在您的 css 文件中添加此样式并根据您的要求制作高度,它可以工作!

.MuiAccordionDetails-root {
  max-height: 300px;
  overflow-y: scroll;
}

codesandbox link: https://codesandbox.io/s/react-typescript-forked-pc3udc?file=/src/styles.css:59-132代码沙盒链接: https ://codesandbox.io/s/react-typescript-forked-pc3udc?file=/src/styles.css:59-132

I have created the answer with sandbox.我已经用沙盒创建了答案。 url I have used sx prop and overflowy to scroll. url我使用了 sx prop 和overflowy 来滚动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM