Crude oil is composed of many hydrocarbons. The crude oil is heated to evaporate it and the vapour rises. There is a temperature gradient up the column (hotter at the bottom, colder at the top). The different hydrocarbons have different boiling points, so condense at different levels and can be collected here.