Calculates the size and the position of a target to fit a container.