Get css-height dynamically and apply as margin?

Get css-height dynamically and apply as margin?

Hello!
I am in a bit of a bind, and wonder if Jquery is the solution to my problem.
I have several divs with class 'textbox', and they have variable heights (due to different amounts of text). I want to select all those divs, get their respective calculated css-height, and apply a negative margin-top on each, consisting of their respective css-height (maybe with an addition of 1rem).

I also need all those margins to be recalculated upon window resize. The resize() event should help me with the last task, but can the former be done? I can apply fixed margins to all the divs but I am not sure if I am misunderstanding the possibility of getting the heights dynamically and applying them as margins?