Set dimensions of an DOM element by ratio