Rewritten title: Center a fixed HTML square or circle element horizontally and vertically when resized
P粉4550931232024-04-04 12:31:51
0
1
454
How to center a square or circular fixed html element of varying sizes horizontally and vertically? I think the difficulty arises from the fact that width and height must remain equal.
I think this problem can be easily solved with flex. Wrap related square or circle elements from a parent element (div). Then use justify-content and align-item properties to the parent tag. Here I use 100vh 100vw as the height and width of the parent container for demonstration. But you can change it according to your purpose.
I think this problem can be easily solved with flex. Wrap related square or circle elements from a parent element (div). Then use justify-content and align-item properties to the parent tag. Here I use 100vh 100vw as the height and width of the parent container for demonstration. But you can change it according to your purpose.