Think about the refractory nature of the varios elements as well as the condensation temperature profile in the initial solar nebula. Also the chemical affinity of some elements for others is a big effect in some cases.
Uranus and Neptune are nowhere near as hydrogen/helium rich as Jupiter and Saturn.
Check out a paper by Lodders. It think it's about the year 2000 and it's on astro/ph.