I have a box with a radial-gradient dot pattern background. When I use the property padding-bottom: 100%
to make it a square, the dot pattern works as expected. When switching to mobile devices, I need this box to be a rectangle, so I changed the padding-bottom to 45%. At 45% the dot pattern is not visible, and if the padding-bottom is anything less than 75% the dot pattern will not show at all. Why is that? What can be done to make the desired effect work. Ideally the pattern would work for any sized box.
Here is a jsfiddle that shows the problem> https://jsfiddle.net/. The red square box has the dot pattern, while the rectangular purple box has no dots.
Any insights or advice would be greatly appreciated.
Here is an image that shows what I am describing:
I thought of a workaround to create a square psuedo element(::before) and apply the repeating radial background to that and add
overflow: hidden
to the rectangle class. I hope this might help you.Note: Make sure that the width and height of
::before
element is larger than the main element.