Basically speaking, opacity means that a fraction of photons in the visible range excite certain electrons in the atoms of the substance, and such an excitation results in absorbance and re-emission of the photons. If the substance's atoms absorb enough of the photons, and/or involve enough frequencies in the stream of photons, then the photons will not reach the opposite side of the substance.
In reality, opacity is a range based upon intensity and frequency. You can understand how, say, a color filter is a very selective absorber of photon frequency. Also, you can understand that even a thin metal foil is a strong absorber of photon intensity. There isn't a substance that is absolutely opaque, as there isn't a substance that is absolutely transparent. It's all up to the atomic composition, and we have only ~90 types of atoms to work with, and largely ~20 of those are used in common materials where transparency would be tested.
Another way to understand this is to recognize that tossing light at an object engages its electrons. If you're tossing a laser at a certain frequency into a material whose atomic structure doesn't engage with that frequency, then that object is largely transparent (noting that there will always be some scattering). If you choose a material for that laser's frequency that has a strong excitation potential, then you should expect the object to be very opaque to the beam. With other sources of photonic emission (not just visible light), other substances have varying degrees of opacity. (A famous example of this is Earth's atmosphere, which is generally transparent to visible light, but is fairly opaque to infrared light ... which is how the "greenhouse effect" seems to function.)