Rumah > Soal Jawab > teks badan
Mengapa imej saya diselaraskan di tengah tetapi tidak di hujung? Saya jadi keliru..
<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粉5485126372023-09-09 12:34:07
Jika anda ingin menyelaraskan tengah-tengah kandungan, anda mesti menggunakan atribut "justifyContent: 'center'". Selain itu, terdapat beberapa isu dengan elemen "Bekas", anda boleh gunakan .
Periksa sama ada ini yang anda ingin capai
<Box sx={{ display: "flex", minHeight: "100vh", alignItems: "center", justifyContent: "center", flexGrow: 1 }} > <Box> <img src="https://static.vecteezy.com/system/resources/previews/001/200/294/original/house-png.png" width={200} alt="img" /> <LinearProgress sx={{ mt: 4 }} /> </Box> </Box>
P粉6804879672023-09-09 09:42:29
Boleh guna Box
包裹 img
<Box sx={{ display: 'flex', minHeight: '100vh', alignItems: "center", flexGrow: 1, }} > <Container maxWidth="sm"> <Box sx={{ display: 'flex', justifyContent: "center" }} > <img src="https://static.vecteezy.com/system/resources/previews/001/200/294/original/house-png.png" width={200} alt="img" /> </Box> <LinearProgress sx={{ mt: 4 }} /> </Container> </Box>