Thank you for the article. Maybe I'm missing something but you could just set padding-bottom to 100% (intrinsics ratio for square is always 100%). No need to calculate anything regarding height, width or padding-bottom.
Hey marjanb, you are right but there is one small issue with using percentage values. As per the specs the padding-bottom is based on the parent element's width and not based on the element itself. so that's not the intention here. I hope its clear.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you for the article. Maybe I'm missing something but you could just set padding-bottom to 100% (intrinsics ratio for square is always 100%). No need to calculate anything regarding height, width or padding-bottom.
Hey marjanb, you are right but there is one small issue with using percentage values. As per the specs the padding-bottom is based on the parent element's width and not based on the element itself. so that's not the intention here. I hope its clear.