As dry ice turns from a solid to a vapor, or sublimes, it produces carbon dioxide gas. Carbon dioxide is denser than air. (Carbon dioxide molecules have an atomic mass of 44 amu [atomic mass units]. Air is made up mostly of nitrogen, 28 amu, and oxygen, 32 amu.) The denser carbon dioxide gas forms a layer on the bottom of the container.
A bubble is full of air. It floats on the carbon dioxide layer, just like a helium balloon floating in the air. You might expect that the air in the bubble would cool and contract near the dry ice, but the bubble actually expands slightly. The soapy wall of the bubble allows carbon dioxide to pass through but keeps air molecules inside. Initially, the concentration of carbon dioxide gas is low inside the bubble and high outside the bubble.
The gas gradually diffuses into the bubble, a process called osmosis. The bubble film is a semipermeable membrane—a surface that allows some substances to pass through while preventing others from doing so. The cells in your body have the same property. Water, oxygen, and carbon dioxide easily enter some cells, whereas other molecules do not. The added carbon dioxide makes the bubble denser, causing it to gradually sink. The carbon dioxide at the bottom of the tank is cold enough to freeze the bubble.