Opal is not crystalline in the usual sense. It is made of amorphous spheres of silica (SiO2) packed closely together. The sphere packing only mimics the extremely ordered arrangement of the much smaller single atoms and ions in the lattice of a true crystal.
Opal sphere lattices are far less ordered. The spheres are of varied size and thus they do not pack together well. Take a box of uniform sized marbles and rattle it well too and fro � the marbles will arrange into a close packed array. Add a few marbles of different size and this no longer happens, there will only be small groups, if any, regularly arranged. The out of size marbles disrupt the close packing.
Precious or gem opal, sought for its flashes of colour, has spheres 150 � 300 nm diameter. In comparison red light has a wavelength of ~600nm. Precious opal has macro sized domains where the spheres are fairly uniform in size and, locally at least, pack into a fairly orderly tetragonal, cubic or hexagonal lattice. These are the domains that can flash colour.
Mechanistically, the colour arises from interference between light waves scattered by each sphere. Since the spheres are regularly spaced, scattered light waves of certain wavelengths will overlap with their waves crests matching. The scattered light will be strengthened. Other wavelengths are less fortunate, their outgoing wave crests do not overlap constructively and their colours are not seen. The result is patches of intense colour . The colour depends on the silica ball size and thus spacing in the small domain.
Mathematically, the colours and directionality are better predicted by regarding an opal domain as a regular 3D array of periodically varying refractive index - which it is. This is a photonic crystal. It transpires that the crystal will transmit some wavelengths but there are also band gaps where transmission is blocked. The blocked wavelengths are scattered back out of the crystal � these are the intense colours that we see.
Photonic crystals arise elsewhere in Nature, for example a peacock�s colours are from 2D crystals. Some butterflies, beetles and fish have them. Photonic crystals have enormous potential application in opto-electronics and elsewhere. Great effort is going into fabricating opal and other structures and even making 'inverse-opal' which can be visualised by filling all the spaces between the balls at right and then dissolving away the spheres!