Trying to maintain vertical rhythm on a page with images of unknown heights is proving to be a challenge. I came across a solution on Stack Overflow, however, since I am using vanilla javascript instead of jquery, utilizing a jquery plugin is not an option for me. The alternative answer involves setting the baseline in JavaScript, but I have already set it in my SCSS files and do not want to duplicate the hard-coded values all over again.
Another potential solution from another Stack Overflow thread involves additional markup that I find cumbersome due to style concerns. It feels reminiscent of the days when nested <div>
tags were necessary just to achieve rounded corners.
An idea emerged to use generated content to pass JSON to JavaScript. However, upon further research, I discovered an example employing the same method, making me question if there could be a better approach.
Is there a more efficient way to accomplish this task? My ultimate goal is to specify that the height of an element must be a multiple of a given value. Some sources suggest that CSS alone cannot achieve this, although I believe calc
might come close - yet, I lack the expertise to implement it effectively. Is there a superior method to transmit the required value to JavaScript?
Any advice or guidance would be greatly appreciated.