'Absorption' lines are caused by resonance scattering (scattering the radiation out of the line of sight, see illustration below), and resonance scattering has a very large cross section of roughly $10^{-12} cm^2$. This means that even for a thin layer of 10km ($10^6 cm$) you need only a density of >$10^6 /cm^3$ of an element for the layer to become opaque in the line center. This is a very small density (a fraction $10^{-9} -10^{-6}$ of the hydrogen density in the lower solar atmosphere depending on the region) and most elements will easily exceed that (see the abundances in the plot in one of the other answers).
(from https://courses.lumenlearning.com/astronomy/chapter/formation-of-spectral-lines/)
EDIT (clarifying a couple of issues addressed in the comments below).
The illustration above can of course not be literally applied in case of the Fraunhofer lines in the solar spectrum. The 'cloud' is in this case a thin spherical shell around the sun, and, as we are observing from the outside, we are only able to see the spectrum with the lines in absorption. However, in principle we could see the other two cases if we could get below the layer; we would then see the lines in emission looking up and the featureless continuum looking down. The emission lines are being reflected back into the sun and are absorbed there (the photosphere can be considered a black body and thus absorbs any radiation falling onto it), so those photons disappear and can not be scattered back again into the absorption lines (as one of the comments was suggesting would be happening if one adopted this explanation).
The crucial point here is that the density of the chromosphere (where most of the Fraunhofer 'absorption' lines are formed) is much too low to be in thermal equilibrium. Atomic line emissions due to local thermal excitation by collisions can be neglected compared to the emission due to scattering of the photospheric radiation. As the chromosphere is nevertheless still optically thick within the lines, this results in the light being largely being scattered back into the photosphere at these frequencies, creating the 'absorption' lines in the process when viewing from the outside.
It also has been mentioned that the process at work here should be described as a separate absorption event followed by a spontaneous re-emission rather than a resonant scattering event (this is actually also implied in the link under the illustration above). Whilst this may seem like a subtle or even semantic issue, it is in fact quite important in some cases. The exact issue was actually already addressed 100 years ago in this paper and clearly suggested that the process that leads to the Fraunhofer lines should be considered as scattering (in the sense as described above) rather than an absorption/emission process. Whilst this paper used a classical approach, the same result is also obtained with Quantum Mechanics. This is derived in detail in §15 (Resonance Fluorescence) of the book 'The Quantum Theory of Radiation' by W. Heitler, which can be found on the Internet Archive. This proves that resonance scattering has to be described as a coherent one-quantum process. This means for instance that monochromatic radiation will again be scattered as monochromatic radiation and not with the natural line width of the transition (which one would see with a spontaneous emission).
This is in fact frequently applied in works regarding radiative transfer in spectral lines (in particular as far as stellar atmospheres are concerned) by incorporating 'partial frequency redistribution' functions that take the coherent nature of the scattering process into account. It is found that this can be crucial in some cases. This paper for instance shows that the observed polarization in the wings of strong Fraunhofer lines can only be explained with the coherent scattering model, with the incoherent 'spontaenous decay' model resulting in zero polarization in the line wings, in contradiction to observations.