简体   繁体   English

如何让我的 Material UI Modal 响应?

[英]How to make my Material UI Modal responsive?

I created a Modal with a Carousel inside of it and I want it to be responsive.我创建了一个模态框,里面有一个旋转木马,我希望它能够响应。 I tried out several CSS settings that I found here on StackOverflow, but none of them worked for me.我尝试了在 StackOverflow 上找到的几个 CSS 设置,但没有一个对我有用。 How can I fix it?我该如何解决?

CSS: CSS:

media: {
    width: "auto",
    paddingTop: "56.25%" // 16:9
  },
modalCard: {
    position: "absolute",
    top: "50%",
    left: "50%",
    transform: "translate(-50%, -50%)",
    width: "50%",
    aspectRatio: "16 / 9",
    margin: "0 auto"
  }

Rnd.jsx: Rnd.jsx:

<Card className={classes.modalCard}>
    <Carousel autoPlay={false} indicators={false} animation="slide">
        {images.map((img, index) => {
            return (<CardMedia className={classes.media} image={img.imgPath} />
        );
      })}
    </Carousel>
</Card>

The project: https://codesandbox.io/s/react-playground-forked-3uggr5?file=/Rnd.jsx:131-139项目: https://codesandbox.io/s/react-playground-forked-3uggr5?file=/Rnd.jsx:131-139

在此处输入图像描述

(Off question: Why do I get that warning?) (关闭问题:为什么我会收到该警告?)

I suggest you to use https://www.npmjs.com/package/react-responsive-carousel .我建议你使用https://www.npmjs.com/package/react-responsive-carousel

I created sandbox here so you can check it.我在这里创建了沙箱,所以你可以检查它。

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

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