I'm trying to display a React Spinner component centered horizontally and vertically in the screen, after search and read different similar answers, for example this post, I could center it horizontally, currently my code is this:
import ClipLoader from "react-spinners/BounceLoader";
function Spinner() {
return (
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
}}
>
<ClipLoader color="#52bfd9" size={100} />
</div>
);
}
export default Spinner;
The result I'm getting is this:
However, I'm dealing how to center it vertically, the nearest I get from the solution is this code:
<div style={{ verticalAlign: 'middle', position:'absolute', top: '50%', left: '50%', marginTop: '-100px', marginLeft: '-250px' }}>
But it is not centered it vertically and horizontally, please take a look at the next image:
My question is: do you have any recommendation how to center vertically and horizontally the div tag and the component?