I have a grid consisting of multiple boxes each sized at 280px by 280px, and I am seeking a way to vertically align text within hover overlays on each box.
While my current code successfully aligns the text for the first box, I am encountering issues due to varying text lengths and heights for each box. I am looking to create a function that dynamically assigns top padding based on the specific paragraph height within each box.
I believe using the .each method could help me achieve this, but my attempts to implement it have been unsuccessful.
Presented below is the code that currently works and requires modification to target each box individually:
var txtHeight = $( ".login-item .lgn-overlay p" ).height();
var topPadding = ((284 - txtHeight) / 2);
$('.login-item .lgn-overlay').css('padding-top', topPadding);