There are two ingredients inside a lava lamp: a watery liquid, and a waxy compound that collects at the bottom when the lamp is turned off. Turn on the light bulb in the lamp's base, and the waxy compound slowly comes to life, wiggling its way up to the top, and finally settling into a complicated dance of waxy globes, some floating up, others floating down. How come?
Density
Whether something sinks or rises in water is determined by its density. If something is more dense than the surrounding water it will sink. If something is less dense it will rise and float. The trick behind a lava lamp is that the waxy compound has almost exactly the same density as the water inside the lamp, and this density changes with temperature. When the wax is cool, it is slightly more dense than the water and it sinks. When it's warm, it gets less dense, and it rises.
Hot And Cold
When you turn on the bulb in the lamp's base, that heats the wax enough so that it starts to rise. When the wax gets to the top, away from the light bulb, it cools enough to sink again. It's this delicate balance of density and temperature that makes a lava lamp's magic.