This is a great question, and one with a complicated answer. It’s all due to quantum mechanics. The following answer is approximately correct: if the structure in question is a crystal (like quartz) then there are a large number of well-defined energy levels that the electrons in the crystal can sit in. If photons are incident at an energy that is sufficient to promote electrons between these energy levels, they are absorbed. If they’re not of that right energy, they’re not. Whether or not something is transparent is therefore a function of its wavelength — the only thing (to my knowledge) that is transparent across the entire EM spectrum is the vacuum.