I've run into an issue with the gap
property in CSS not working as expected in my layout. After investigating, I found that some of my containers have display: block;
set, which seems to be causing the gap
property to be ineffective. My goal is to create space between elements within a container using gap
.
Below is a simplified version of my CSS setup:
.centered-div {
display: block; /* Causing issues */
/* Other properties */
gap: 24px; /* Not functioning properly */
}
I am aware that gap
is typically used with flex containers (display: flex;
or display: inline-flex;
). However, changing display: block;
to display: flex;
is not an option for this specific container due to layout restrictions.
Is there a way to achieve spacing between elements (gap
) without switching from display: block;
to display: flex;
? Alternatively, is there another method I can utilize to achieve similar spacing effects in a non-flex container?
Any assistance or advice on this matter would be highly appreciated. Thank you!