Calculate the top and bottom position