This article is from the Aquaria: Disease, Algae and Snails FAQ, by Elaine Thompson, Thomas Sasala and George Booth
Fish floats upside-down or sideways. This is particularly common in
fancy goldfish because of their bizarre body shapes. Dry food eaten
quickly swells up in the fish's intestine and keeps the fish from
controlling its swim bladder properly.
To help, feed the fish pre-soaked or gel-based foods. Green foods are
also helpful; peas in particular.
As with finrot, these disorders can also be caused by bacterial
infection. Treatment is much the same. Use antibiotic food if the fish
is eating, or add antibiotic to the water in a quarantine tank if the
fish is too sick to eat.