The new basalt magma formed from the parent peridotite is less dense than the rock around it, so it begins to rise. At some point the rising magma gets within a few kilometers of the seafloor. Then it begins to cool and minerals may start to crystallize. The first mineral to form is the one with the highest melting temperature--magnesium-rich olivine. This is true even though the magnesium-rich olivine in the peridotite did not melt very much.
The new olivine is denser than the magma, so it sinks. This changes the composition of the liquid magma even further. Later, as the magma keeps cooling, new plagioclase feldspar starts to form. This plagioclase is rich in calcium, and it floats. If the plagioclase crystals float up and out of the magma, the magma composition changes again, becoming calcium-poor.
By now the magma has probably accumulated in a magma chamber, not too far from the seafloor. Liquid that escapes from the magma chamber will pass upward through a narrow dike. If it reaches the seafloor it will erupt, forming shiny black glass and fine-grained basalt. Melt trapped in the magma chamber will form and grow mineral crystals and becomes coarser grained gabbro. If our best models of ocean crust structure are correct, there are 10 x 107 km3 of gabbro, making it by far Earth's most abundant crustal rock! Yet the contact between gabbro and the overlying volcanic rocks, like a deep, buried secret, has never been recovered from the ocean.