Answer
Mantle-derived magmas with a basaltic composition can generate magmas of intermediate to felsic composition through a process called fractional crystallization. As the basaltic magma rises toward the Earth's surface, it undergoes cooling and begins to solidify. Certain minerals, like olivine and pyroxene, crystallize at higher temperatures, leaving behind a more silica-rich residual melt.
This residual melt, enriched in silica and other elements, becomes more viscous and can evolve into magmas with intermediate compositions, such as andesite. Further fractional crystallization can then generate felsic magmas, like rhyolite, which have even higher silica content.
Work Step by Step
Please refer to the above answer.