首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用sx道具旋转背景图像

使用sx道具旋转背景图像
EN

Stack Overflow用户
提问于 2022-07-27 23:49:26
回答 1查看 34关注 0票数 0

我试图使用MU5 'sx‘支持语法旋转背景图像,我不知道如何做,似乎找不到答案。我只想旋转背景图像,但不是网格的任何子组件:

代码语言:javascript
复制
 <Grid container direction='column'sx={{
                    backgroundImage: `url(${Image})`, transform: 'rotate(90deg)', backgroundSize: '100% 100%',
                    backgroundPosition: 'top left', backgroundRepeat: 'no-repeat',
                }}>

  </Grid>
EN

回答 1

Stack Overflow用户

发布于 2022-07-28 00:56:53

没有background-image转换,但是如果不想旋转任何子元素,可以使用伪元素::before,添加背景图像并旋转,如下所示:

代码语言:javascript
复制
<Box
      sx={{
        width: 300,
        height: 300,
        position: "relative",
        border: "dashed 3px royalBlue",
        overflow:'hidden',
        ":before": {
          content: "''",
          width: "100%",
          height: "100%",
          position: "absolute",
          zIndex: "-1",
          transform: "rotate(30deg)",
          backgroundImage:
            "url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScz4ccW2Mc2m5qU4rRicqn5lk7EN4qxsjLitrENxkiYPo7SC1hAkFd4BbTgxJhEov9iTc&usqp=CAU)"
        }
      }}
    >
      <Box sx={{ p: "10px", backgroundColor: "orange", color: "white" }}>
        Child 1 dddd
      </Box>
      <Box sx={{ p: "10px", backgroundColor: "orange", color: "white" }}>
        Child 2 dddd
      </Box>
      <Box sx={{ p: "10px", backgroundColor: "orange", color: "white" }}>
        Child 3 dddd
      </Box>
    </Box>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73145757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档