Home > Mobile >  Make a div appear in front of another in Material UI when you hover
Make a div appear in front of another in Material UI when you hover

Time:10-05

How do I make a black transparent div appear in front of a <MediaCard/> when I hover over it?

This is what I'm returning using Material UI:

    <Box>
  <Typography variant='h3'>Home Page</Typography>
  <Typography sx={{ 'margin': '15px 0' }}>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  </Typography>
  <Container sx={{ marginTop: '100px' }}>
    <Grid container spacing={6}>
      {cards.map(card => {
        return (
          <Grid item>
            <MediaCard {...card} />
          </Grid>
        );
      })}
    </Grid>
  </Container>
</Box >

CodePudding user response:

You can use CSS Codesandbox Demo

References

CodePudding user response:

<Grid item sx={{ ":hover": { filter: "brightness(50%)" }, 
  transition: "all .2s" }}
>
  <MediaCard {...card} />
</Grid>
  • Related