Ok, you should add a tag : 'geometry'.
First thing, remember to sine and cosine, then take a calculator :
rotation around the x assis is 45 degrees
The cos of 45 it's around 0,7, then//value of cos for 45 degrees
0.7*150=106 //the height of the rectangle afther transformation
(150-106)/2 //the space remaining in the parent up and down the element divided by 2
the result is 22 and this is positive top or the negative bottom you need.
Same for the second block: (250-(0.7*250))/2 = 37.5
Remember to recalculate the value of the angle if you change it. More rounded the numbers are, more you will be accurate. Remember that calulation can be heavy for many tag.