When I added absolute to the image, the image was centerd.
I want to center an image tag and a p tag with a div tag, and I want the div tag to be centered with absolute, but it is not centered
import { FunctionComponent } from 'react';
const Index: FunctionComponent = () => {
return (
<>
<img
src="profile.svg"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
margin: 'auto',
}}
/>
</>
);
};
export default Index;
const Index: FunctionComponent = () => {
return (
<>
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
margin: 'auto',
}}
>
<img src="profile.svg" />
<p>name</p>
</div>
</>
);
};
export default Index;