MUI: Align and adjust image center in flexbox
P粉550323338
P粉550323338 2023-09-08 18:20:02
0
2
321

Why is my image centered but not aligned? I'm confused..

<Box
      sx={{
        display: 'flex',
        minHeight: '100vh',
        alignItems: 'center',
        flexGrow: 1,
      }}>
      <Container maxWidth="sm">
        <img src="https://static.vecteezy.com/system/resources/previews/001/200/294/original/house-png.png"
          width={200}
          alt="img"
        />
        <LinearProgress sx={{ mt: 4 }} />
      </Container>
    </Box>
P粉550323338
P粉550323338

reply all(2)
P粉548512637

If you want to center-align the content, you must use the "justifyContent: 'center'" attribute. Also, there are some issues with the "Container" element, you can use .

Check if this is what you want to achieve


  
    img
    
  

Demo on Codesandbox

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!