The structure of the energy bands determines opacity.
Work Step by Step
In an ionic crystal, which is insulating because electrons are immobile, the energy gap is large. There are no easily accessible energy states for electrons in the filled valance band to go if they were to absorb a visible photon, so the photon passes through unimpeded. In contrast, in a metal, the conduction band is already partially filled, and electrons can absorb photons, making the material opaque.